A colleague has just introduced me to the history command. This allows you to list the recent history of commands used on the command line.
This is ideal when using the command line on a regular basis. One example is that I do a great deal of development on my local machine so when I eventually come to connect to the remote server I have to keep typing the ssh command out.
By typeing history on the command line you get a numbered list of all the commands. Now this on its own isn’t really useful but when coupled with the following becomes extremely useful.
If you now type !number and press enter this will execute the command. (Number is the number of the item from the returned list)
Better still if you do the following… !number:p this prints the command to the list so you can then edit the command if some parameters need to be changed.
It gets better… yu can filter the returned list by using the grep command. history | grep “search term”
Use the above command to print the required command to the command line and away you go.







