6 ms·
Infinite Bang Bang
- suhail_ansari 13y agoawesome!
- cskau 13y agoAlas! A no-go in fish: ~ !! fish: Unknown command “!!”
- shadykiller 13y agoYes .. only sh and bash ...in zsh, the series does grow but not so explosively
- ics 13y agoThis is probably the only worst thing I've encountered since switching my desktop to fish. Can you write a fish function and name it !!?
- sikhnerd 13y agoThis is covered in the faq: http://ridiculousfish.com/shell/user_doc/html/faq.html#faq-history http://ridiculousfish.com/shell/user_doc/html/faq.html#faq-h...
- Sir_Cmpwn 13y agoThat seeems... silly. `sudo !!` feels vastly superior to "Up, Home, `sudo `" Mostly because !! is right there and Up+Home are over there.
- ent 13y agoDoing this too many times is really not a great idea. My machine started grinding to a halt _after_ I had killed the bash that was pumping out all the bangs. Reboot didn't fix it. Deleting my 2 gig ~/.bash_history did :)
- shadykiller 13y agohaha .. that is so funny :P I did warn, though about not running it for the 7th iteration unless you want 125 million bang bangs in your history file :)
- guard-of-terra 13y agoBash history completion is sometimes useful (!mysql) but mostly annoying (using ! somewhere mid-sentence) !! is pointless because up arrow, come on.
- dr4g0n 13y ago!! is not at all pointless, "sudo !!" is much easier that Up, Ctrl-a, "sudo ".
- guard-of-terra 13y agoI have alt-s in my zsh which does zle beginning-of-line; zle -U "sudo " Also it's up, home, "sudo "
- dr4g0n 13y agoI may have to steal that alias, good tip. Ctrl-a/Ctrl-e are equivalent to Home/End (unless you're inside a screen session, which was a terrible choice of binding on their part).
- phaemon 13y agoNote that these aren't bash things. They're the emacs bindings for readline, so they work with anything that uses readline (like the mysql client). You can set them to the vi ones instead with: set -o vi ..and they do work with screen ;-) (0 for start, $ for end)
- chimeracoder 13y ago> escape \000\040 in my screenrc changes this to 'CTRL+spacebar', which I find much more sensible.
- xxpor 13y agoor sudo ESC-. which inserts the last word from the last command.
- gbaygon 13y agoI think that the author is a little confused, the linked image in not the original XKCD (http://xkcd.com/149/ http://xkcd.com/149/)
- shadykiller 13y agoNot confused .. I had initially only had the image and not XKCD link until someone asked me to credit them .. I added the link without noticing the text. .removed the link now :)
- gbaygon 13y agoI mentioned it because I've seen that xkcd and didn't learn about the bang syntax until today. Great Article.
- shadykiller 13y agoThanks :) This is my first article to break into HN top 10 and also got me max upvotes
- vog 13y agoThe author's approximation of 125 million bangbangs in the 7th iteration is quite good. The actual number is: 159591041 I wrote a small Python script that allows for further analysis outside the shell: https://github.com/vog/bangbang https://github.com/vog/bangbang
- shadykiller 13y agoAwesome . .even I was close to 150 million but never the exact number anyway .. thanks for this
- shadykiller 13y agoDo you have the exact number for the 8th iteration ?
- vog 13y agoUnfortunately, no. The script actually calculates strings, then counts the bangbangs. The 7th iteration took about 4 GiB RAM (temporarily, and 2 GiB in the end). Using this approach, I don't think there's enough RAM for the 8th iteration on this planet. The algorithm would have to be optimized quite a lot before it could calculate the exact 8th value.
- vog 13y agoOkay, I finally found a way that gets us one more iteration. The exact next value is: 168668479408755201 Assuming your approximation "7 Quadrillion" means 7e15 (rather than 7e24 [1]), this is about 24 times as much. [1] http://en.wikipedia.org/wiki/Quadrillion http://en.wikipedia.org/wiki/Quadrillion
- shadykiller 13y agoI am still skeptical for this . . the basic approximation formula gives a ballpark .. and when I put 159 million in the formula it gives me 12640500079500000 which is 12 quadrillion ... http://www.tools4noobs.com/online_tools/number_spell_words/ http://www.tools4noobs.com/online_tools/number_spell_words/ Reason I say this is - let's assume all 159 million bangs are expanded then 159*159 millions = 25 quadrillion
- jasonkostempski 13y agoI used to use a password that ended in !! before I knew about the command, before I even seriously used Linux. It caused problems setting up MySQL and even caused issues for a domain host while transferring a domain of mine. I don't use that password anymore :)
- ygra 13y agoBut using things that break other things from time to time is probably still a good idea to find software defects. I used to have a user on my machine whose name (and thus profile folder) contained a non-Latin-1 letter and a space.
- madaxe 13y agoThis goes in the same bucket of fun that contains :(){ :|:& };: Don't run that on a shell unless you enjoy having to physically reboot servers.
- fnayr 13y agoWhat does it do? Definitely not going to try it.
- swirepe 13y agoIt makes a function called :, which calls itself. More or less.
- madaxe 13y agoPipes itself into a new instance of itself every time, thus spawning processes geometrically. Hence, Fork Bomb.
- unoti 13y agoIt makes a function called : which spawns processes, and each of those processes spawns more processes calling itself.
- jellicle 13y agoFor the curious: https://en.wikipedia.org/wiki/Fork_bomb https://en.wikipedia.org/wiki/Fork_bomb
- zeckalpha 13y agoShould this series be added to the OEIS? https://oeis.org/search?q=1%2C2%2C3%2C5%2C17%2C161%2C15681 https://oeis.org/search?q=1%2C2%2C3%2C5%2C17%2C161%2C15681
- vog 13y agoI'm about to add it. For this, I had to register for an account, confirmed my email address, but I'm still waiting for the final account creation.
- vog 13y agoI finally added this sequence as A228162. Here is the draft that waits for review: https://oeis.org/draft/A228162 https://oeis.org/draft/A228162
- jamesmaniscalco 13y agoTrying to figure out a mathematical representation of this sequence... I noticed that different patterns emerge when you subtract 1 from each value in the sequence. From there we get: 0 1 2 4 16 160 15680 159591040 16866847940875520 Each (excluding 0 and 1) is a multiple of the previous term: 1 2 = 1 * 2 4 = 2 * 2 16 = 4 * 4 160 = 16 * 10 15680 = 160 * 98 159591040 = 15680 * 10178 16866847940875520 = 159591040 * 105687938 Anything ring a bell? Notice any other patterns?
- jamesmaniscalco 13y agoAlso, subtracting 2 from each of those numbers produces a similar pattern: 2 - 2 = 0 2 - 2 = 0 4 - 2 = 2 10 - 2 = 8 = 2 * 4 98 - 2 = 96 = 8 * 12 10178 - 2 = 10176 = 96 * 106 105687938 - 2 = 105687936 = 10176 * 10386
- vog 13y agoFurther analysis by Robin Houston: https://news.ycombinator.com/item?id=6227115 https://news.ycombinator.com/item?id=6227115 Newly registered OEIS sequence: https://oeis.org/A228162 https://oeis.org/A228162