Using History Interactively Bash History Builtins
When the `
-o history' option to the
is enabled (see The Set Builtin),
the shell provides access to the command history,
the list of commands previously typed. The text of the last
commands (default 500) is saved in a history list. The shell
stores each command in the history list prior to parameter and
but after history expansion is performed, subject to the
values of the shell variables
When the shell starts up, the history is initialized from the
file named by the
HISTFILE variable (default `
HISTFILE is truncated, if necessary, to contain no more than
the number of lines specified by the value of the
variable. When an interactive shell exits, the last
HISTSIZE lines are copied from the history list to
histappend shell option is set (see Bash Builtins),
the lines are appended to the history file,
otherwise the history file is overwritten.
is unset, or if the history file is unwritable, the history is
not saved. After saving the history, the history file is truncated
to contain no more than
HISTFILESIZE is not set, no truncation is performed.
The builtin command
fc may be used to list or edit and re-execute
a portion of the history list.
history builtin can be used to display or modify the history
list and manipulate the history file.
When using the command-line editing, search commands
are available in each editing mode that provide access to the
The shell allows control over which commands are saved on the history
variables may be set to cause the shell to save only a subset of the
shell option, if enabled, causes the shell to attempt to save each
line of a multi-line command in the same history entry, adding
semicolons where necessary to preserve syntactic correctness.
shell option causes the shell to save the command with embedded newlines
instead of semicolons.
See Bash Builtins, for a description of