fc (built-in Bash command)

Content

 

Data

License: GNU GPLv3 +
Version number: GNU Bash 5
Developer / owner: Free Software Foundation Inc.

Short description:

The manual page and help for the fc built-in Bash command. You can use fc to print, modify, and re-execute previous commands. FIRST and LAST can be numbers that specify a range, or FIRST can be a string that represents the last command that begins that way.

 

 

Man page output

man bash
[...]
       fc [-e ename] [-lnr] [first] [last]
       fc -s [pat=rep] [cmd]
              The first form selects a range of commands from first to last from the history list
              and displays or edits and re-executes them.  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 com-
              mand 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 edit-
              ing and -16 for listing.

              The -n option suppresses the command numbers when listing.  The -r option  reverses
              the  order  of the commands.  If the -l option is given, the commands are listed on
              standard output.  Otherwise, the editor given by ename is invoked on  a  file  con-
              taining those commands.  If ename is not given, the value of the FCEDIT variable is
              used, and the value of EDITOR if FCEDIT is not set.  If neither variable is set, vi
              is used.  When editing is complete, the edited commands are echoed and executed.

              In  the  second form, command is re-executed after each instance of pat is replaced
              by rep.  Command is interpreted the same as first above.  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 command.

              If the first form is used, the return value is 0 unless an invalid  option  is  en-
              countered 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-executed, unless cmd does not specify a
              valid history line, in which case fc returns failure.
[...]

 

 

Help output

fc --help
fc: fc [-e ename] [-lnr] [első] [utolsó] vagy fc -s [minta=csere] [parancs]
    Parancsok megjelenítése vagy végrehajtása az előzményből.
    
    Az fc segítségével lehet korábbi parancsokat kiírni, módosítani és újból
    végrehajtani.
    Az ELSŐ és UTOLSÓ lehetnek egy tartományt meghatározó számok, vagy az ELSŐ
    lehet egy karakterlánc, amely az utolsó így kezdődő parancsot jelöli.
    
    Kapcsolók:
      -e ENAME  szerkesztő kiválasztása. Az alapértelmezett az FCEDIT,
                majd EDITOR, végül a vi
      -l        szerkesztés helyett a sorok listázása
      -n        sorok számának elhagyása listázáskor
      -r        sorrend megcserélése (legújabbakkal kezdi a listázást)
    
    Az „fc -s [minta=csere] [parancs]” formával PARANCS... újból végrehajtásra
    kerül, miután a régi=új behelyettesítés megtörtént.
    
    Hasznos lehet az „alias r='fc -s'” használata, mivel így pl. az „r cc”
    parancs végrehajtja az utolsó „cc”-vel kezdődő parancsot, míg „r” meg-
    ismétli az utolsó parancsot.
    
    Kilépési kód:
    Sikert vagy a végrehajtott parancs kilépési kódját adja; nullától eltérőt
    hiba esetén.

 

Related Content