Command History
The shell's history mechanism allows you to recall previous events (commands) and then repeat them. To enable command history, set the history shell variable in ˜/.cshrc to the number of events that you want the shell to remember. To preserve your history across logins, set the savehist shell variable.
The history command displays your current history:
history Display entire history list historynDisplay lastnevents from history list
History Event Specifiers
History references begin with a ! character. When the shell sees such a reference, it replaces it in the command line, echoes the resulting command, and executes it.
The event specifiers listed below select commands from the history list:
Specifier | Description |
|---|---|
| Repeat previous command |
| Repeat command |
| Repeat |
| Repeat last command beginning with |
| Repeat last command containing |
| Repeat the current command line typed so far |
Word Designators
The word designators listed below extract particular words from an event:
Designator | Description |
|---|---|
| Word 0 (the command name) |
| Word |
| Word 1 |
| Last word |
| Words |
| Words 0 through |
| Words |
| Words 0 through (but not including) last word |
| Words |
| Words 1 through last word, or empty if there are no arguments |
| Following a |
Word designators are usually separated from the preceding event specifier by a colon. However, some shortcuts may ...
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