Unix Shell Shortcuts

Here are a few shell shortcuts:

!! 
Repeats the most recent command.

!t 
Repeats the most recent command beginning with "t". Similarly for other letters, or strings of initial letters in a command. This is very handy when going through a compiling/running/editing cycle. For example, if you work on a latex document, after giving the full command names "latex file", "xdvi file", "dvips file", during the first cycle, you can then repeat the steps using the shortcuts "!l", "!x", "$d". (Be careful, though; if you type "!r" instead of "!t", you may inadvertently repeat the last delete command.)

dvips !$ 
This executes dvips with the last argument of the most recent command. For example, after doing "xdvi verylongfilename", the above command will run the file "verylongfilename" through dvips. Similarly, after editing a file with "vi verylongfilename", you can print out the file by saying "lpr verylongfilename".

history 
Gives a list of the most recent commands. Useful if you want to repeat a command, but don't remember the exact form you used. The number of commands saved in this way can be changed by adding a line such as "set history = 1000" in the .cshrc file.

history | grep 'perl' 
List all commands within the saved command history matching 'perl'.


!1729 
Repeat command number 1729 in the history listing.

Up/down arrows 
As an alternative to the exclamation mark commands, you can use the up/down arrows to move back and forth in the command history and repeat/edit a command.