The ! command is used to recall previous commands in your command history for re-execution. The ! command is unique in that when it is used, it leaves the matching history entry in the input line for re-editing. You can specify a history entry either by its number in the history list, or by a match with a given wildcard expression. For example: !10 will put entry 10 in the history list into the input line. The following: !/MSG will search the history list for a line beginning with /msg and put it in the input line (an * is implied at the end of /msg). When using ! command with a wildcard expression, subsequent uses of the ! command continue their search in the history list from where they left off. This is reset to the end of the list when a command is executed that adds an entry to the history list. Also, if a wildcard expression is used once, subseqent uses of ! with no expression will use the previous wild card expression. For example, the following: !/MSG ! The first call returns the first match of /MSG in the history list, and the second returns the next match, and so on. Lastly, ! may be used in command aliases as well. When it is embedded in an alias it simply executes the matching history entry without first putting it in the input line for re-editing.
See Also: history
Top level index