Repeat last executed command

!!
I don't know why this ain't written as simply as it is. I always see it's just used as parameter, like: vi `!!` But i use it to repeat a command, as i always work on several shells and check the result of one shell on a second.

-3
By: Blackbit
2009-07-16 08:07:35

These Might Interest You

  • Use yes to repeat (it will continue until the pipe breaks) https://en.wikipedia.org/wiki/Yes_(Unix) head -n5 to repeat the piped command n times. https://en.wikipedia.org/wiki/Head_(Unix) Show Sample Output


    0
    echo "$(yes '+' | head -n5)"
    Artistan · 2017-12-31 19:12:23 0
  • repeat a command every X seconds , output show the creation of partition image using fsarchiver, each line show the size of the image. Show Sample Output


    -2
    while x=0; do foo ; sleep 1 ; done
    eastwind · 2012-07-11 13:22:21 1
  • Pressing a key will now repeat normally, instead of bringing up the accent/more options menu.


    0
    defaults write -g ApplePressAndHoldEnabled -bool false
    JimFriend · 2014-06-06 17:46:36 0
  • PING parameters c 1 limits to 1 pinging attempt q makes the command quiet (or silent mode) /dev/null 2>&1 is to remove the display && echo ONLINE is executed if previous command is successful (return value 0) || echo OFFLINE is executed otherwise (return value of 1 if unreachable or 2 if you're offline yourself). I personally use this command as an alias with a predefined machine name but there are at least 2 improvements that may be done. Asking for the machine name or IP Escaping the output so that it displays ONLINE in green and OFFLINE in red (for instance).


    9
    ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINE
    UnixNeko · 2012-02-09 06:30:55 7

What Others Think

i think buttons arrow up and enter more practical than this command
unixmonkey4681 · 462 weeks and 2 days ago
especially when you need to just: sudo !!
linuxrawkstar · 462 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: