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


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 11.7 History Substitutions Chapter 11
The Lessons of History
Next: 11.9 Running a Series of Commands on a File
 

11.8 Repeating a Cycle of Commands

The !! history substitution gives a copy of the previous command. Most people use it to re-execute the previous command line. Sometimes I want to repeat a cycle of two commands, one after the other. To do that, I just type !-2 (second-previous command) over and over:

% 

vi plot


   ...
% 

vtroff -w plot


   ...
% 

!-2


vi plot
   ...
% 

!-2


vtroff -w plot
   ...

You can cycle through three commands with !-3 , four commands with !-4 , and so on. The best part is that if you can count, you never have to remember what to do next. :-)

- JP


Previous: 11.7 History Substitutions UNIX Power Tools Next: 11.9 Running a Series of Commands on a File
11.7 History Substitutions Book Index 11.9 Running a Series of Commands on a File

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