Searching Shell History

You can search for commands in your history, to start a reverse shell history search, type Ctrl + r. Your prompt changes to reflect that you are performing a search. Start typing in characters from the previous command that you are searching for. If the first result returned is not what you are looking for, type Ctrl + r again to get the next previous match. To execute the command as it is, simply press the Enter key. If you want to modify the command before executing it use the and arrow keys to start navigating the command line. Make your changes, and type Enter to execute the command. To cancel your search and return to the prompt type Ctrl + g

Examples

Example 1: Perform reverse search

To perform a reverse search, enter Ctrl + r, then you will see that the prompt changes to say you are performing a reverse search.

(reverse-i-search)`': 

Then, simply type what you would like to search. If the one is not you are looking for, you can use Ctrl + r again to get the next previous command. To execute the searched command, simply press Enter key. To change command, use and arrow keys. To cancel a reverse search, use Ctrl + g.

References & Resources

  • N/A