history: Event Designators

1 
1 1.1.1 Event Designators
1 -----------------------
1 
1 An event designator is a reference to a command line entry in the
1 history list.  Unless the reference is absolute, events are relative to
1 the current position in the history list.
1 
1 '!'
1      Start a history substitution, except when followed by a space, tab,
1      the end of the line, or '='.
1 
1 '!N'
1      Refer to command line N.
1 
1 '!-N'
1      Refer to the command N lines back.
1 
1 '!!'
1      Refer to the previous command.  This is a synonym for '!-1'.
1 
1 '!STRING'
1      Refer to the most recent command preceding the current position in
1      the history list starting with STRING.
1 
1 '!?STRING[?]'
1      Refer to the most recent command preceding the current position in
1      the history list containing STRING.  The trailing '?' may be
1      omitted if the STRING is followed immediately by a newline.
1 
1 '^STRING1^STRING2^'
1      Quick Substitution.  Repeat the last command, replacing STRING1
1      with STRING2.  Equivalent to '!!:s/STRING1/STRING2/'.
1 
1 '!#'
1      The entire command line typed so far.
1