In Bash (and most readline-based applications like it) you can press Ctrl-R
to bring up a history search function:
$ date
Tue Feb 1 15:40:06 EET 2011
(reverse-i-search)`d': date
By pressing Enter
here I get:
$ date
Tue Feb 1 15:40:06 EET 2011
$ date
Tue Feb 1 15:40:52 EET 2011
EDIT:
You can see the full list of history-related Bash keystrokes here.
You can see the current list of history search keyboard bindings:
$ bind -P | grep search | grep history
forward-search-history can be found on "\C-s".
history-search-backward can be found on "\e[5~".
history-search-forward can be found on "\e[6~".
non-incremental-forward-search-history can be found on "\en".
non-incremental-forward-search-history-again is not bound to any keys
non-incremental-reverse-search-history can be found on "\ep".
non-incremental-reverse-search-history-again is not bound to any keys
reverse-search-history can be found on "\C-r".
In my case Page-Up/Down can also be used to search for commands that start with whatever I have already typed, as configured in my /etc/inputrc
:
# Page Up/Down cycles through history only for matching entries
"\e[5~": history-search-backward # Previous
"\e[6~": history-search-forward # Next