Command history substitution
Use the fc built-in command to list or edit portions of the history file. To select a portion of the file to edit or list, specify the number or the first character or characters of the command.
You can specify a single command or range of commands.
If you do not specify an editor program as an argument to the fc regular built-in command, the editor specified by the FCEDIT variable is used. If the FCEDIT variable is not defined, then the /usr/bin/ed file is used. The edited command or commands are printed and run when you exit the editor.
The editor name hyphen (-
) is used
to skip the editing phase and run the command again. In this case, a substitution
parameter of the form Old=New
can be used to modify the command
before it is run. For example, if r
is aliased to fc
-e -
, then typing r bad=good c runs the most
recent command that starts with the letter c
and replaces
the first occurrence of the bad
string with the good
string.