Go to the first, previous, next, last section, table of contents.
When used interactively, the shell keeps a list of recently entered
commands - known as the
history.
This
history
is accessable through
History Expansion
the use of which is described under
Command Editting
and though the
history
built in command.
The number of lines of history that is kept is governed by the HISTORY variable which defaults to 100.
The history is stored as lines of text, just as they were read in, with the location of the beginning of each word remembered. Thus, the exact entered text can be recovered, either as whole lines, or as sequences of one or more words.
History expansion is signalled by an exclamation point. As the processing of history expansion is done very early, the only quoting that can be used to disable history expansion is to precede the exclamation point with a slosh (sloshchar!).
Following this exclamation point is a history line identifier and a history word identifier. Either of these may be empty, and it may be necessary to separate them with a colon if they are not otherwise distinguishable.
The line identifier can be any one of the following:
!-1gives the last command.
The word identifier is one of the following where n is a decimal integer or a circumflex (^) indicating 1, and m is a decimal integer, a dollar sign ($), or a dollar sign followed by a hyphen and a decimal integer. If the dollar sign is used it refers to the maximal meaningful number. A dollar sign followed by a hyphen and a number means that number less than the maximal meaningful number.
As a special case, if both line identifier and word identifier are empty, no substitution is done.
Go to the first, previous, next, last section, table of contents.