Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the fc command of linux to edit and execute history commands

Shulou Source: shulou.com Published: 2022-06-02 15:24:15 10月06日 Update

This article will explain in detail about using linux's fc command to edit and execute history commands. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The EXTENDED_HISTORY environment variable affects the execution of the fc command. If the variable is set to ON, the time is recorded, otherwise the time is not recorded.

Syntax format: fc [parameters]

Commonly used parameters: coach

-e specifies the text editor used to edit commands. By default, vi-l lists the history commands within the scope of the first and last commands. If you do not follow the command range, the default displays the 16 most recently used history commands.-n displays history commands without displaying the command sequence number-r shows all history commands in reverse order-s finds the specified command from the current position in the history command and executes it

Reference example

Display a list of historical commands (print the last 16 historical commands by default):

[root@linuxcool ~] # fc-l

Specify the editing commands using the ex text editor:

[root@linuxcool] # fc-e ex

Displays a list of historical commands but does not display the command sequence number:

[root@linuxcool ~] # fc-n

Display all historical commands in reverse order:

[root@linuxcool ~] # fc-r

Find the find command from the history command and execute:

[root@linuxcool ~] # fc-s find about using linux's fc command to edit and execute the history command is shared here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Commands history parameters variables sequence numbers text time more articles editors ranges references good practical location content destiny examples commonly used articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Redmi MariaDB Docker