Bash.Builtin.Fc (Bash v0.6.0)

Copy Markdown View Source

fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [cmd]

fc is used to list or edit and re-execute commands from the history list. FIRST and LAST can be numbers specifying the range, or FIRST can be a string, which means the most recent command beginning with that string.

Options: -e ENAME Select which editor to use (default: $FCEDIT, $EDITOR, or vi) -l List lines instead of editing -n Suppress line numbers when listing -r Reverse the order of the lines

With the fc -s [pat=rep ...] [command] format, the command is re-executed after the substitution OLD=NEW is performed.

A useful alias to use with this is r='fc -s', so that typing r cc runs the last command beginning with cc and typing r re-executes the last command.

Note: Interactive editing with -e is not supported in this implementation. Use fc -l to list and fc -s to re-execute with substitution.

Exit Status: Returns success unless an invalid option is supplied or an error occurs.

Reference: https://cgit.git.savannah.gnu.org/cgit/bash.git/plain/builtins/fc.def?h=bash-5.3