## 30.3. My Favorite Is !$

I use `!$` so much that it's almost a single character to me. It means "take the last thing on the previous command line." 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 (Section 39.2). To extract and edit a file from them, I first make a backup for easy comparison after editing:

  >     % tar xzf prog.1.05.tar.gz foo.c
  >     % cp -i !$ !$.orig
  >     cp -i foo.c foo.c.orig

  The same trick is also good when you've edited a file with vi and then want to check its spelling:

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

- 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

Copyright © 2003 O'Reilly & Associates. All rights reserved.