start page | rating of books | rating of authors | reviews | copyrights

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 11.1 The Lessons of History Chapter 11
The Lessons of History
Next: 11.3 My Favorite Is !$
 

11.2 History in a Nutshell

The C shell and bash can save copies of the previous command lines you type. Later, you can ask for a copy of some or all of a previous command line. That can save time and retyping.

This feature is called history substitution , and it's done when you type a string that starts with an exclamation point ( ! command ). You can think of it like variable substitution ( $ varname ) ( 6.8 ) or command substitution ( ` command ` ) ( 9.16 ) : the shell replaces what you type (like !$ ) with something else (in this case, part or all of a previous command line).

Article 11.1 is an introduction to shell history. These articles show lots of ways to use history substitution:

One last note: putting the history number in your prompt ( 7.2 ) makes it easy to re-use commands that haven't scrolled off your screen.

- JP


Previous: 11.1 The Lessons of History UNIX Power Tools Next: 11.3 My Favorite Is !$
11.1 The Lessons of History Book Index 11.3 My Favorite Is !$

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