home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 11.2 History in a Nutshell Chapter 11
The Lessons of History
Next: 11.4 My Favorite Is !:n*
 

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


Previous: 11.2 History in a Nutshell UNIX Power Tools Next: 11.4 My Favorite Is !:n*
11.2 History in a Nutshell Book Index 11.4 My Favorite Is !:n*

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System