Using History in the command line
In the last few months i’ve come across some great little things that make using the terminal (in OSX) lots more fun. Here’s one of them…
History.
The history command simply lists the the history of commands entered into the terminal. Used with grep this enables you to find and use previously typed commands.
For example
mac1:~ mevans$ history | grep mysql
3 mysqld5 &
4 mysql5
5 mysql_safe5
6 mysqld_safe5
331 ps ax | grep mysql
You can then use any of these commands again using a ! - eg. !331