fc

Official Description

Allows the user to fix previously executed commands through command-line editing.

Syntax

fc [-r] [-e editor] [first [last]]
fc -l [-nr] [first [last]]
fc -s [old=new] [command ]

Options

-r reverses the search order.

-e enables you to choose a different editor (the default is ed).

-l lists previous commands.

-n does not display command numbers for previous commands.

-s substitutes new for old in the command (old is the old string to be replaced by the new string).

Oddities

Typically performed using a command-line editor.

The history command is an alias for fc: history='fc -l'.

The r command (recall) is an alias for fc: r='fc -e -'.

Example

 $ fc -l 1412 print $myvar 1413 ksh 1414 print $myvar 1415 exit 1416 print $myvar ...

Get Korn Shell Programming by Example 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.