Command History
Previously executed commands are stored in a history list. The C shell lets you access this list so you can 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 four ways to use the history list:
Rerun 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 following subsections describe the csh tools for editing and rerunning commands. If you are running tcsh, you can use any of these features. In addition, you can use the arrow keys to move around in the command line and then use the editing features described in Section 8.7.5 to modify the command. The tcsh 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. |
Command Substitution
Command | Description |
---|---|
!
| Begin a history substitution. |
!!
| Previous command. |
!
N
|
Command number |
!-
N
|
|
!
string
|
Most recent command that starts with |
!?
string ? |
Most recent command that contains |
!?
string?%
|
Most recent command argument that contains |
!$
| Last argument of previous command. |
!!
string
|
Previous command, then append |
!
N string
|
Command N, then append |
!{
s1 }s2 |
Get Linux in a Nutshell, Third 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.