O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The 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. See the fc entry in the section Built-in Commands in Built-in Commands for more information.

Examples

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required