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 and
history 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 Section 21.7.5, 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 doesn’t have the
command-line editing features of tcsh, these
tools are important for rerunning commands. With
tcsh, they are less often used, but they still
work.
Command Substitution
|
Command |
Description |
|---|---|
|
|
Begin a history substitution. |
|
|
Previous command. |
|
|
Command number |
|
|
|
|
|
Most recent command that starts with
|
|
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access