fc
NAME
fc - The first form selects a range of commands from first to last from the history list and displays or edits and re-executes themSYNOPSIS
fc [-e ename] [-lnr] [first] [last]
fc -s [pat=rep] [cmd]
DESCRIPTION
The first form selects a range of commands from first to last from the history list and displays or edits and re-executes them. First and last may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the current command number). If last is not specified it is set to the current command for listing (so that ``fc -l -10'' prints the last 10 commands) and to first otherwise. If first is not specified it is set to the previous command for editing and -16 for listing.
The -n option suppresses the command numbers when listing. The -r option reverses the order of the commands. If the -l option is given, the commands are listed on standard output. Otherwise, the editor given by ename is invoked on a file containing those commands. If ename is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set. If neither variable is set, vi is used. When editing is complete, the edited commands are echoed and executed.
In the second form, command is re-executed after each instance of pat is replaced by rep. Command is intepreted the same as first above. 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.
If the first form is used, the return value is 0 unless an invalid option is encountered or first or last specify history lines out of range. If the -e option is supplied, the return value is the value of the last command executed or failure if an error occurs with the temporary file of commands. If the second form is used, the return status is that of the command re-executed, unless cmd does not specify a valid history line, in which case fc returns failure.
SEE ALSO
This is extracted from the main bash man page, see there for more details.