Name

fc

Synopsis

    fc [options] [first [last]]
    fc -e - [old=new] [command]
    fc -s [old=new] [command]

ksh88 and Bash. Display or edit commands in the history list. (Use only one of -e, -l or -s.) first and last are numbers or strings specifying the range of commands to display or edit. If last is omitted, fc applies to a single command (specified by first). If both first and last are omitted, fc edits the previous command or lists the last 16. The second form of fc takes a history command, replaces old with new, and executes the modified command. If no strings are specified, command is just reexecuted. If no command is given either, the previous command is reexecuted. command is a number or string like first. See the examples in the earlier section "Command History.” The third form, available in Bash and ksh93, is equivalent to the second form.

Options

-e [ editor ]

Invoke editor to edit the specified history commands. The default editor is set by the shell variable FCEDIT. If that variable is not set, the default is /bin/ed. (Bash defaults to vi; version 3.1 and newer will default to /bin/ed when in POSIX mode.) Bash tries FCEDIT, then EDITOR, and then /bin/ed.

-e -

Execute (or redo) a history command; refer to second syntax line above.

-l

List the specified command or range of commands, or list the last 16.

-n

Suppress command numbering from the -l listing.

-r

Reverse the order of the -l listing.

-s

Equivalent to -e -. Not in ksh88.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.