In the terminal, I can type Ctrl + R to search for a matching command previously typed in BASH. E.g., if I type Ctrl + R then grep
, it lists my last grep
command, and I can hit enter to use it. This only gives one suggestion though. Is there any way to cycle through other previously typed matching commands?
Bash – How to Cycle Through Reverse-i-Search
bash
Best Answer
If I understand the question correctly you should be able to cycle through alternatives by repeatedly hitting Ctrl + R.
E.g.:
grep
That searches backwards through your history. To search forward instead, use Ctrl + S, but you may need to have set:
stty -ixon
(either by.bash_profile
or manually) prior to that to disable the XON/XOFF feature which takes over Ctrl + S. (More details here.)