//View Tip #24
Similar Tips
» Up/down arrow keys for searching history
» Fix the previous command
» Disable bash history
» Adding times to the history
» See your favorite commands

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Don't search history by grepping ~/.bash_history, or repeatedly hitting the up arrow, instead use CTRL+r (or '/' in vi-mode) for search-as-you type. You can immediately run the command by pressing Enter.


View Comments »




Comments 

Add your comment

Comments are currently disabled
That is ~brilliant~! 20 years (on and off) of playing with *nix and I'd not seen that one..!
Posted 2008-11-11 21:15:28
Whilst I use Ctrl-R often, sometimes grepping history is easier to get the exact command you want, so I setup an alias

alias ghis='history | grep'

and then use !<n> ,where n = history #
Posted 2009-01-02 05:14:53
Stu
If you run "cat /proc/acpi/thermal_zone/THRM/temperature", then later want to run the same command, you can use a history expansion.
!cat
gives you the most recent bash history line that begins with "cat". You can also use a wildcard (?)
!?temp
Posted 2009-03-11 06:37:20
And then try CTRL-O instead of Enter.
Posted 2010-03-02 04:32:40

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit