Tuesday, June 4, 2013

Reverse search bash command history

Ctrl + r => start reverse command search

Ctrl +r/s again  to move up and down the search list.

Example:

Suppose the command history contains the following command that start with "sudo"

10. sudo yum install gvim
......a bunch of other commands
20. sudo yum update -y
...other commands
30. sudo umount /mnt/disk1

Pressing "Ctrl+r" and typing "sudo" will find the last used command that matches "sudo" i.e line #30. To move up and down the list press "ctrl+r" and "ctrl+s"