fc command
Table of Contents
fc Command
fc stands for either find command
or fix command
, since it does both jobs. Use fc -l
to list history commands and fc -e
to edit them.
Examples
Command | Description |
---|---|
history | List the last 16 commands |
fc -l 20 30 | List commands 20 through 30 |
fc −l −5 | List the last five commands |
fc -l cat | List all commands since the last command beginning with cat |
fc -l 50 | List all commands since command 50 |
fc -ln 5 > doit | Save command 5 to file doit |
fc -e vi 5 20 | Edit commands 5 through 20 using vi |
fc -e vi -1 -8 | Edit last 8 commands using vi editor |
fc -e emacs | Edit previous command using emacs |
Interactive line editing is easier to use than fc
, since you can move up and down in the saved command history using your favorite editor commands (as long as your favorite editor is either vi or Emacs!). You can also use the Up and Down arrow keys to traverse the command history and the right and left arrow keys to move around in the command line.
Reference:
- The fc Command - Linux in a Nutshell, 6th Edition [Book]
- https://www.geeksforgeeks.org/fc-command-linux-examples
Enjoy Reading This Article?
Here are some more articles you might like to read next: