The text of the last HISTSIZE commands entered from a terminal is saved in a history file. The default value for HISTSIZE is 128. If the HISTFILE variable is not set or if the file denoted by its value is not writable, the file $HOME/.sh_history is used to save the command history.
A POSIX shell can access the commands of all interactive shells which use the same history file. The built-in fc command can be used to list or edit a portion of this file. The portion of the file to be edited or listed can be selected by number or by giving the first character or characters of the command. A single command or range of commands may be specified.
If you do not specify an editor program as an argument to fc, the value of the variable FCEDIT is used. If FCEDIT is not defined, /usr/bin/ed is used. The edited commands are printed and re-executed when you leave the editor.
The editor name - (if FCEDIT=-) is used to skip the editing phase and to directly re-execute the command. In this case a substitution variable of the form old=new can be used to modify the command before execution. For example, if r is aliased to fc -e -, then typing r bad=good c will re-execute the most recent command which starts with the letter c, replacing the first occurrence of the string bad with the string good.