Chapter 30.Using History InteractivelyThis chapter describes how to use the GNU History Library interactively, from a user’s standpoint. Itshould be considered a user’s guide.30.1. History ExpansionThe History library provides a history expansion feature that is similar to the history expansion pro-vided by csh. This section describes the syntax used to manipulate the history information.History expansions introduce words from the history list into the input stream, making it easy torepeat commands, insert the arguments to a previous command into the current input line, or fix errorsin previous commands quickly.History expansion takes place in two parts. The first is to determine which line from the history listshould be used during substitution. The second is to select portions of that line for inclusion into thecurrent one. The line selected from the history is called the event, and the portions of that line that areacted upon are called words. Various modifiers are available to manipulate the selected words. Theline is broken into words in the same fashion that Bash does, so that several words surrounded byquotes are considered one word. History expansions are introduced by the appearance of the historyexpansion character, which is ! by default.30.1.1. Event DesignatorsAn event designator is a reference to a command line entry in the history list.!Start a history substitution, except when followed by a space, tab, the end of the line, = or (.!nRefer to command line n.!-nRefer to the command n lines back.!!Refer to the previous command. This is a synonym for !-1.!stringRefer to the most recent command starting with string.!?string[?]Refer to the most recent command containing string. The trailing ? may be omitted if thestring is followed immediately by a newline.^string1^string2^Quick Substitution. Repeat the last command, replacing string1 with string2. Equivalent to!!:s/string1/string2/.