|
|
History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.
History expansion is performed immediately after a complete line is read, before the shell breaks it into words. It takes place in two parts. The first is to determine which line from the history list to use during substitution. The second is to select portions of that line for inclusion into the current one. The line selected from the history is the event\fP, and the portions of that line that are acted upon are words\fP. Various modifiers\fP are available to manipulate the selected words. The line is broken into words in the same fashion as when reading input, so that several metacharacter\fP-separated words surrounded by quotes are considered one word. History expansions are introduced by the appearance of the history expansion character, which is \^!\fP\^ by default. Only backslash (\^\\fP\^) and single quotes can quote the history expansion character.
Several shell options settable with the shopt builtin may be used to tailor the behavior of history expansion. If the histverify shell option is enabled (see the description of the shopt builtin), and readline is being used, history substitutions are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the readline editing buffer for further modification. If readline is being used, and the histreedit shell option is enabled, a failed history substitution will be reloaded into the readline editing buffer for correction. The -p option to the history builtin command may be used to see what a history expansion will do before using it. The -s option to the history builtin may be used to add commands to the end of the history list without actually executing them, so that they are available for subsequent recall.
The shell allows control of the various characters used by the history expansion mechanism (see the description of histchars above under .BR "Shell Variables" ).
Web: http://shell.tjgy.com Email:support@tjgy.com