[Chapter 11] 11.3 My Favorite Is !$
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:36:05Z

#

| Chapter 11 The Lessons of History |

## 11.3 My Favorite Is !$

When using the C shell, I use `!$` so much that it's almost a single character to me. It means "take the last thing on the previous command line." It works on bash too. Since most UNIX commands have the filename last, you often need to type filenames only once, and then you can use `!$` in subsequent lines. Here are some examples of where it comes in handy:

- I get a lot of tar archives (19.5) that are compressed (24.7). To unpack them, I do the following:

  >     % gunzip groff.1.05.tar
  >     % tar xvf !$
  >     tar xvf groff.1.05.tar

  The same trick can be used for uuencoded shar files (19.2). It's also good when you've edited a file with vi, and then want to check its spelling:

  >     % vi fred.letter.txt
  >     % spell !$
  >     spell fred.letter.txt

- You often want to move a file to another directory and then `cd` to that directory. The `!$` sequence can also be used to refer to a directory:

  >     % mv grmacs.tar /usr/lib/tmac
  >     % cd !$
  >     cd /usr/lib/tmac

- AN

11.2 History in a Nutshell |  | 11.4 My Favorite Is !:n*