Search back through previous commands

Ctrl-R <search-text>
Searches backwards through your command-history for the typed text. Repeatedly hitting Ctrl-R will search progressively further. Return invokes the command.
Sample Output
ssmith:~$ <Ctrl-r>rsy
(reverse-i-search)`rsy': rsync -Pazv .wine filehost:
<return>
ssmith:~$ rsync -Pazv .wine filehost:
....

14
2009-09-20 05:07:31

These Might Interest You

  • This is not actually a command, it's just a keyboard shortchut. But a very useful one. Show Sample Output


    6
    ctrl + r
    sixtus · 2009-02-20 13:28:19 1
  • Here the !!:1 will take the first parameter from the previous command. This can be used in conjunction with other history commands like ! and so on. Show Sample Output


    16
    !!:[position]
    raj77_in · 2010-05-24 08:09:23 1
  • This is an extension of a previous command by satyavvd on 2009-07-23 12:04:02, but this one grabs the whole archive. Hard coded numbers in previous script capped number of commands that could be fetched. This one grabs them all regardless of how big the archive gets. Show Sample Output


    0
    for x in `jot - 0 \`curl "http://www.commandlinefu.com/commands/browse"|grep "Terminal - All commands" |perl -pe 's/.+(\d+),(\d+).+/$1$2/'|head -n1\` 25`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done >a.txt
    stinkerweed999 · 2009-08-25 21:57:15 2
  • Use the following key binding to search ---------------------------------------------------------------- ng : Jump to line number n. Default is the start of the file. nG : Jump to line number n. Default is the end of the file. /pattern : Search for pattern. Regular expressions can be used. [/ = slash] Press / and then Enter to repeat the previous search pattern. Press ESC and then u to undo search highlighting. n : Go to next match (after a successful search). N : Go to previous match. mletter : Mark the current position with letter. 'letter : Return to position letter. [' = single quote] '^ or g : Go to start of file. '$ or G : Go to end of file. s : Save current content (got from another program like grep) in a file. = or Ctrl+g : File information. F : continually read information from file and follow its end. Useful for logs watching. Use Ctrl+c to exit this mode. -option : Toggle command-line option -option. h : Help.


    -4
    less file.ext
    totti · 2011-09-13 10:29:27 3

What Others Think

You can also run 'stty -ixon' and use Ctrl-S to do a forward search (Ctrl-R is a reverse search). Ctrl-G will bring you back to a blank command line.
TimeTrap · 224 weeks and 5 days 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: