set -o history enables the history (default on for interactive shells).
The history list is initialized from
When an interactive shell exits, the last
$HISTSIZE lines are copied from the history list to
$HISTFILE (or appended based on
histappend ) and then truncated to
$HISTCONTROL control the text of the command, prior to parameter and variable expansion but after history expansion.
$HISTTIMEFORMAT time stamp is included with each entry, marked with the history comment character. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps.
fc lists or edits and re-execute a portion of the history list.
history displays or modifys the history list and manipulate the history file.
When using command-line editing, search commands are available in each editing mode that provide access to the history list (see Commands For History).
$HISTIGNORE may be set to cause the shell to save only a subset of the commands entered.
cmdhist 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.
lithist (Literal History) causes the commands to be saved with embedded newlines
shopt sets these options.
fc [-e editor] [-lnr] [first] [last]
fc -s [pat=rep] [command]
last may be strings (to locate the most recent command beginning with that string) or numbers (an index into the history list. A negative number is used as an offset from the current command number).
first is not specified it is set to the previous command for editing and -16 for listing.
last is not specified it is set to first.
-l the commands are listed on standard output.
-n no command numbers are shown.
-r reverses the order of the listing.
vi is invoked on a file containing those commands.
When editing is complete, the edited commands are echoed and executed.
fc -s [pat=rep] [command]
command is executed after all
pat replaced by
A useful alias is
r='fc -s', so that typing
r cc runs the last command beginning with
cc and typing
r re-executes the last command (see Aliases).
history -d offset
history [-anrw] [filename]
history -ps arg
Display the last
n lines of the history list with line numbers,
* prefix indicates modified line.
$HISTTIMEFORMAT (default sometimes:
%F %T) format string for
strftime to display the time stamp with each entry.
829 2016-02-17 16:03:39 vi diskUtilityDefaultsAll.html 830 2016-02-17 16:12:57 chmod 704 diskUtilityDefaultsAll.html 831 2016-02-17 16:13:15 vi defaults.1.html 832 2016-02-17 18:25:30 cd docs 833 2016-02-17 18:25:32 lt 834 2016-02-17 18:25:40 ls -l disk*
-w, -r, -a, or
-n is used, if filename is given, then it is used as the history file otherwise
$HISTFILE is used.
enabled by default for interactive shells, and can be disabled using the +H option to the set builtin command.
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 parts.
!by default. Only
'may be used to escape the history expansion character.
Several shell options settable with the shopt builtin (see Bash Builtins) may be used to tailor the behavior of history expansion.
histverify shell option is enabled, 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 expansion will be reloaded into the Readline editing buffer for correction.
-p to the history builtin command may be used to see what a history expansion will do before using it.
-s adds commands to the end of the history list without actually executing them, so that they are available for subsequent recall. This is most useful in conjunction with Readline.
The shell allows control of the various characters used by the history expansion mechanism with the histchars variable, as explained above (see Bash Variables). The shell uses the history comment character to mark history timestamps when writing the history file.
:separates the event specification from the word designator. It may be omitted if the word designator begins with a
!!last argument of the preceding command.
!$. second argument of the most recent command starting with the letters fi.
If a word designator is supplied without an event specification, the previous command is used as the event.