Bash - fc (Fix Command) - Range of command from history - (builtin)

Bash Liste Des Attaques Ovh


Fix Command (fc) is a builtin command that retrieve a range of commands from first to last is selected from the history list.


First form

fc has two modes:

  • editing (default).
  • listing (-l option)
fc [-e ename] [-nlr] [first] [last]


  • first and last define the range. See first_and_last
  • -n: No number. It suppresses the command numbers when listing.
  • -r: Reverse order: option reverses the order of the commands.
  • -l: Listing: The commands are listed on standard output.
  • ename: editor name. Edit the file in this editor if the -l option is not given. See editor

If neither variable is set, is used. When editing is complete, the edited commands are echoed and executed.

First and last

  • first and last may be specified as:
    • a string (to locate the last command beginning with that string)
    • or as a number (an index into the history list, where a negative number is used as an offset from the current command number).
  • If last is not specified it is set to the current command for listing (so that fc -l -10 prints the last 10 commands) and to first otherwise.
  • If first is not specified it is set to the previous command for editing and -16 for listing.


If ename is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set.

see Linux - Shell Editor


  • fc -l -10 prints the last 10 commands

Second form

Command is re-executed after each instance of pat is replaced by rep.

fc -s [pat=rep] [cmd]

A useful alias to use with this is ‘‘r=“fc -s”’’, so that typing ‘‘r cc’’ runs the last command beginning with ‘‘cc’’ and typing ‘‘r’’ re-executes the last com- mand.

If the first form is used, the return value is 0 unless an invalid option is encountered or first or last specify history lines out of range. If the -e option is supplied, the return value is the value of the last command executed or failure if an error occurs with the temporary file of commands. If the second form is used, the return status is that of the command re-exe- cuted, unless cmd does not specify a valid history line, in which case fc returns failure.

Documentation / Reference

Discover More
Bash Liste Des Attaques Ovh
Bash - Builtin Commands

builtin refers to: a builtin command. See or to the specific builtin command. See (useful when defining a function whose name is the same as a shell builtin) The builtin command execute the specified...
Linux - Shell Editor

console text editor in Linux A lot command use the environment variable EDITOR to choose their editor. See The most known is VIM

Share this page:
Follow us:
Task Runner