First and last
- 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.
If ename is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set.
- fc -l -10 prints the last 10 commands
Command is re-executed after each instance of pat is replaced by rep.
fc -s [pat=rep] [cmd]
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 com- mand.
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-exe- cuted, unless cmd does not specify a valid history line, in which case fc returns failure.