GNU Info

Info Node: (bashref.info)Bash History Builtins

(bashref.info)Bash History Builtins


Next: History Interaction Prev: Bash History Facilities Up: Using History Interactively
Enter node , (file) or (file)node

Bash History Builtins
=====================

   Bash provides two builtin commands which manipulate the history list
and history file.

`fc'
          `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
          `fc -s [PAT=REP] [COMMAND]'

     Fix Command.  In the first form, a range of commands from FIRST to
     LAST is selected from the history list.  Both FIRST and LAST may
     be specified as a string (to locate the most recent 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
     FIRST.  If FIRST is not specified it is set to the previous
     command for editing and -16 for listing.  If the `-l' flag is
     given, the commands are listed on standard output.  The `-n' flag
     suppresses the command numbers when listing.  The `-r' flag
     reverses the order of the listing.  Otherwise, the editor given by
     ENAME is invoked on a file containing those commands.  If ENAME is
     not given, the value of the following variable expansion is used:
     `${FCEDIT:-${EDITOR:-vi}}'.  This says to use the value of the
     `FCEDIT' variable if set, or the value of the `EDITOR' variable if
     that is set, or `vi' if neither is set.  When editing is complete,
     the edited commands are echoed and executed.

     In the second form, COMMAND is re-executed after each instance of
     PAT in the selected command is replaced by REP.

     A useful alias to use with the `fc' command is `r='fc -s'', so
     that typing `r cc' runs the last command beginning with `cc' and
     typing `r' re-executes the last command (Note: Aliases).

`history'
          history [N]
          history -c
          history -d OFFSET
          history [-anrw] [FILENAME]
          history -ps ARG

     With no options, display the history list with line numbers.
     Lines prefixed with a `*' have been modified.  An argument of N
     lists only the last N lines.  Options, if supplied, have the
     following meanings:

    `-c'
          Clear the history list.  This may be combined with the other
          options to replace the history list completely.

    `-d OFFSET'
          Delete the history entry at position OFFSET.  OFFSET should
          be specified as it appears when the history is displayed.

    `-a'
          Append the new history lines (history lines entered since the
          beginning of the current Bash session) to the history file.

    `-n'
          Append the history lines not already read from the history
          file to the current history list.  These are lines appended
          to the history file since the beginning of the current Bash
          session.

    `-r'
          Read the current history file and append its contents to the
          history list.

    `-w'
          Write out the current history to the history file.

    `-p'
          Perform history substitution on the ARGs and display the
          result on the standard output, without storing the results in
          the history list.

    `-s'
          The ARGs are added to the end of the history list as a single
          entry.

     When any of the `-w', `-r', `-a', or `-n' options is used, if
     FILENAME is given, then it is used as the history file.  If not,
     then the value of the `HISTFILE' variable is used.


automatically generated by info2www version 1.2.2.9