Command History
Previously executed commands are stored in a history list. You
can access this list to verify commands, repeat them, or execute
modified versions of them. The history built-in command displays the
history list; the predefined variables histchars
, history
, and savehist
also affect the history mechanism.
There are a number of ways to use the history list:
Rerun a previous command
Edit a previous command
Make command substitutions
Make argument substitutions (replace specific words in a command)
Extract or replace parts of a command or word
The easiest way to take advantage of the command history is to use the arrow keys to move around in the history, select the command you want, and then rerun it or use the editing features described in the section "Command-Line Editing,” later in this chapter, to modify the command. The arrow keys are:
Key |
Description |
Up arrow (↑) |
Previous command. |
Down arrow (↓) |
Next command. |
Left arrow (←) |
Move left in command line. |
Right arrow (→) |
Move right in command line. |
The next sections describe some tools for editing and rerunning commands. With the C shell, which does not have the command-line editing features of tcsh , these features are important for rerunning commands. With tcsh, they are less often used, but they still work.
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.