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


Unix Power ToolsUnix Power ToolsSearch this book

30.11. Check Your History First with :p

Here's how to be more sure of your history before you use it. First, remember that the history substitutions !/ and !fra are replaced with the most recent command lines that started with / and fra, respectively.

If your memory is like mine (not very good), you might not be sure that !/ 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:

# !/:p
/usr/sbin/sendmail -qv
# !!
/usr/sbin/sendmail -qv
Running id12345...

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

-- JP



Library Navigation Links

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