Bash – Searching command history

bashcommand historyterminal

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?

Best Answer

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
Related Question