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


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 11.9 Running a Series of Commands on a File Chapter 11
The Lessons of History
Next: 11.11 Picking Up Where You Left Off
 

11.10 Check Your History First with :p

Here's how to be more sure of your history before you use it. First, some review of csh and bash history substitutions:

  • !/ and !fra are replaced with the most recent command lines that started with / and fra , respectively.

  • !?af? is replaced with the most recent command line that contained af anywhere on the line.

But if your memory is like mine (not very good), you might not be sure that !?af? will bring back the command you want. You can test it by adding :p to the end. The shell will print the substitution but won't execute the command line. If you like what you got, type !! to execute it. For example:

% !?af?:p


lp afile bfile cfile
% !!


lp afile bfile cfile
request id is 676

At the first prompt, the :p meant the command line was only printed. At the second prompt, I didn't use :p and the lp command was executed. The :p works with all history operators, not just with !?...? .

- JP


Previous: 11.9 Running a Series of Commands on a File UNIX Power Tools Next: 11.11 Picking Up Where You Left Off
11.9 Running a Series of Commands on a File Book Index 11.11 Picking Up Where You Left Off

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