← 返回命令列表

Linux command

fc 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Edit and rerun

fc

List recent commands

fc -l

List commands without

fc -ln [10] [20]

Rerun command

fc -s [15]

Edit specific command

fc [20]

说明

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.

参数

-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.

FAQ

What is the fc command used for?

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.

How do I run a basic fc example?

Run `fc` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l do in fc?

List commands without editing.