fc (Unix)

fc
DevelopersVarious open-source and commercial developers
Operating systemUnix, Unix-like
PlatformCross-platform
TypeCommand

fc (short for fix command) is a shell command that lists, edits and re-executes commands previously entered in the shell. It is particularly helpful for editing complex, multi-line commands. Originally developed for Unix and standardized by POSIX, the command is available in many operating systems today.

As it is required to be "intrinsic" by POSIX, it is implemented as a builtin in the Bash, Zsh, and Almquist shells.

Invoked with no options, the command opens a text editor, allowing the user to modify the last-run command. Upon exiting the editor, the modified command is executed in the current shell. The editor used can be specified with the -e option; otherwise it is read from the FCEDIT environment variable, or, in some shells, EDITOR, with a fallback to vi or ed. Command-line options allow for quick substitution, repetition or modification of a specific command from the session history, or a range of commands from the history.