bash: Bash History Facilities

1 
1 9.1 Bash History Facilities
1 ===========================
1 
11 When the '-o history' option to the 'set' builtin is enabled (⇒The
 Set Builtin), the shell provides access to the "command history", the
1 list of commands previously typed.  The value of the 'HISTSIZE' shell
1 variable is used as the number of commands to save in a history list.
1 The text of the last '$HISTSIZE' commands (default 500) is saved.  The
1 shell stores each command in the history list prior to parameter and
1 variable expansion but after history expansion is performed, subject to
1 the values of the shell variables 'HISTIGNORE' and 'HISTCONTROL'.
1 
1    When the shell starts up, the history is initialized from the file
1 named by the 'HISTFILE' variable (default '~/.bash_history').  The file
1 named by the value of 'HISTFILE' is truncated, if necessary, to contain
1 no more than the number of lines specified by the value of the
1 'HISTFILESIZE' variable.  When a shell with history enabled exits, the
1 last '$HISTSIZE' lines are copied from the history list to the file
11 named by '$HISTFILE'.  If the 'histappend' shell option is set (⇒
 Bash Builtins), the lines are appended to the history file, otherwise
1 the history file is overwritten.  If 'HISTFILE' is unset, or if the
1 history file is unwritable, the history is not saved.  After saving the
1 history, the history file is truncated to contain no more than
1 '$HISTFILESIZE' lines.  If 'HISTFILESIZE' is unset, or set to null, a
1 non-numeric value, or a numeric value less than zero, the history file
1 is not truncated.
1 
1    If the 'HISTTIMEFORMAT' is set, the time stamp information associated
1 with each history entry is written to the history file, marked with the
1 history comment character.  When the history file is read, lines
1 beginning with the history comment character followed immediately by a
1 digit are interpreted as timestamps for the following history entry.
1 
1    The builtin command 'fc' may be used to list or edit and re-execute a
1 portion of the history list.  The 'history' builtin may be used to
1 display or modify the history list and manipulate the history file.
1 When using command-line editing, search commands are available in each
11 editing mode that provide access to the history list (⇒Commands For
 History).
1 
1    The shell allows control over which commands are saved on the history
1 list.  The 'HISTCONTROL' and 'HISTIGNORE' variables may be set to cause
1 the shell to save only a subset of the commands entered.  The 'cmdhist'
1 shell option, if enabled, causes the shell to attempt to save each line
1 of a multi-line command in the same history entry, adding semicolons
1 where necessary to preserve syntactic correctness.  The 'lithist' shell
1 option causes the shell to save the command with embedded newlines
1 instead of semicolons.  The 'shopt' builtin is used to set these
1 options.  ⇒Bash Builtins, for a description of 'shopt'.
1