fc
list, edit, and re-execute shell commands
TLDR
Edit and rerun last command
SYNOPSIS
fc [options] [first] [last]
DESCRIPTION
fc is a shell builtin for listing, editing, and re-executing commands from history. It opens commands in an editor for modification before execution, enabling quick fixes to previous commands.
The command can list history entries, open single commands or ranges in an editor, and directly re-execute commands with optional text substitution. The default editor is taken from FCEDIT, EDITOR, or vi.
fc is particularly useful for fixing typos in long commands or re-running complex pipelines with modifications.
PARAMETERS
FIRST
First command (number or string).LAST
Last command in range.-l
List commands without editing.-n
Suppress command numbers in listing.-r
Reverse order of listing.-s [OLD=NEW]
Rerun command, optionally with substitution.-e EDITOR
Use specified editor.
CAVEATS
Only works with interactive shell history. Editing spawns external editor. Substitution syntax is limited. History must be enabled.
HISTORY
fc (fix command) is a POSIX-specified shell builtin present in Korn shell, Bash, and Zsh. It originated in the Korn shell as a way to edit and re-execute command history entries.
