A surefire shortcut to Insert the Last Argument of the Last Command
peter@tiger:~$ ls -l Windows_20081110102654.log
-rw-r--r-- 1 peter peter 808 2008-11-10 10:26 Windows_20081110102654.log
peter@tiger:~$ cat !$
cat Windows_20081110102654.log
.....
.....
peter@tiger:~$
Then, I discovered that typing Alt-dot achieves the same result. That is, press (and hold) the Alt key, then the dot key.
There are some advantages of using Alt-dot over !$. First, you can actually see the argument immediately and interactively. You can verify that is indeed what you want, edit it if necessary, before you continue the command-line input, and eventually hit Enter to execute the command. With !$, you better have a pretty good memory.
Another advantage is that you can repeatedly type Alt-dot. The net effect is that you scroll back in command history, and display the last argument of each successive command.
After assimilating the shortcut into my command-line work habit, I found that I have been using it a lot. Give it a try!
PS Related entries from this blog: