An event designator is a reference to an entry in the history list. The event designator consists of the portion of the word beginning with the history expansion character, and ending with the word designator if one is present, or the end of the word. Unless the reference is absolute, events are relative to the current position in the history list.
!
Start a history substitution, except when followed by a space, tab, the end of the line, ‘=’, or the rest of the shell metacharacters defined above (see Definitions).
!n
Refer to history list entry n.
!-n
Refer to the history entry minus n.
!!
Refer to the previous entry. This is a synonym for ‘!-1’.
!string
Refer to the most recent command preceding the current position in the history list starting with string.
!?string[?]
Refer to the most recent command preceding the current position in the history list containing string. The trailing ‘?’ may be omitted if the string is followed immediately by a newline. If string is missing, this uses the string from the most recent search; it is an error if there is no previous search string.
^string1^string2^
Quick Substitution.
Repeat the last command, replacing string1 with string2.
Equivalent to !!:s^string1^string2^
.
!#
The entire command line typed so far.