Bash shell trick: searching interactively through command history

Mon, Dec 9

Although the up/down arrow are nice to move through commands in a Bash shell, searching takes the command history to a whole new level.

To start a search within Bash, enter Control-R, the prompt will then change to look as follows:

(reverse-i-search)`':

As you type, matches will be shown, with the cursor directly on the character where the match occurs.

- Hit enter to run the command as is
- Hit Command-R to find more matches
- Type (or delete) characters to refine search
- Type left or right arrow key to edit command (before running)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>