History lists for the C shell

The history list saves commands that the shell reads from the command line that consist of one or more words. History substitution reintroduces sequences of words from these saved commands into the input stream.

The history shell variable controls the size of the history list. You must set the history shell variable either in the .cshrc file or on the command line with the built-in set command. The previous command is always retained regardless of the value of the history variable. Commands in the history list are numbered sequentially, beginning with 1. The built-in history command produces output similar to the following:
9 write michael
10 ed write.c
11 cat oldwrite.c
12 diff *write.c

The shell displays the command strings with their event numbers. The event number appears to the left of the command and represent when the command was entered in relation to the other commands in the history. It is not usually necessary to use event numbers to refer to events, but you can have the current event number displayed as part of your system prompt by placing an exclamation mark (!) in the prompt string assigned to the PROMPT environment variable.

A full history reference contains an event specification, a word designator, and one or more modifiers in the following general format:
Event[.]Word:Modifier[:Modifier] . . . 
Note: Only one word can be modified. A string that contains blanks is not allowed.

In the previous sample of history command output, the current event number is 13. Using this example, the following refer to previous events:

Item Description
!10 Event number 10.
!-2 Event number 11 (the current event minus 2).
!d Command word beginning with d (event number 12).
!?mic? Command word containing the string mic (event number 9).

These forms, without further modification, simply reintroduce the words of the specified events, each separated by a single blank. As a special case, !! refers to the previous command; the command !! alone on an input line reruns the previous command.