Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
up vote 6 down vote accepted

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
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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