History Substitutions: Overview

  • Overview: shell (csh, tcsh, bash) remembers previous command lines. Can edit interactively, but substitution is sometimes faster.
  • Each command line has history number.
  • Can recall command lines by history number or by string-matching.
  • !identifier is replaced by part or all of previous command line:
    % !!        ...substituted with previous command
    % lpr !$    ...last argument of previous command
    % !23       ...all of command 23
    % lpr !23:$ ...last argument of command 23
    % !vi       ...all of the last vi command
    % lpr !vi:$ ...last argument of last vi command
    ...and many more!
  • ^old^new does quick substitution to previous command line:
    % emasc /usr/local/src/foo/file.c
    emasc: command not found.
    % ^sc^cs
    emacs /usr/local/src/foo/file.c
< previous  index  next >


Contact Jerry Peek