I search the terminal command history by pressing Ctrlr but what if:

This is an old command

This is an | less -S older command

I press Ctrlr and then I type "this is an" and the old command commes up but not the older. How can I search all the "this is an" commands? Is it possible to pipe all similar commands to grep or something?

If I set -o vi, how do I undo it?

  • 3
    to undo vi-style line editing just set -o emacs since there only exists emacs and vi line editing mode. – user1146332 Sep 11 '12 at 12:34

To search for a command in the history press ctrl+r multiple times ;-)

You can also grep through the history using:

 history | grep YOUR_STRING

If I understand correctly and you want to search for older entries, just press ctrl+r again.

  • 1
    How can i toggle through them after I enter a search criteria? – powder366 Jan 13 '18 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.