history man page on 4.4BSD

Man page or keyword search:  
man Server   1065 pages
apropos Keyword Search (all sections)
Output format
4.4BSD logo
[printable version]

HISTORY(1)							    HISTORY(1)

       -, --, -p, --p - shell history programs

       - [pattern...]  [substitution...]

       This  set  of programs provides a crude history mechanism for the shell
       rc(1).  It is based on the v8 UNIX programs =, ==, etc.

       The program ``-'' runs the shell on the	command	 it  is	 requested  to
       find.   The  program  ``--''  edits  that  command first.  The programs
       ``-p'' and ``--p'' are similar, except that they print the  final  com‐
       mand on their standard output instead of running the shell.

       The  commands work by looking for a file named by the environment vari‐
       able $history, and by searching for previous  commands  in  this	 file.
       Old  commands  can  be  edited,	or simply re-executed according to the
       rules below:

       A command is searched for by examining the lines in $history in reverse
       order.	Lines  which contain a previous invocation of the history pro‐
       gram itself are ignored.	 If one or more pattern	 is  supplied  on  the
       command	line,  then  the  patterns are used as a means of limiting the
       search.	Patterns match any substring of a  previous  command,  and  if
       more  than  one	pattern	 is  present then all patterns must be matched
       before a command is selected.

       Substitutions may also be specified on the command  line.   These  have
       the syntax:


       (Note  that the old pattern is used as a search-limiting pattern also.)
       Substitutions happen on the first match.

       Finally, a command may be edited in a crude line-mode fashion: The line
       to  be  edited is printed out, and below it the user supplies modifica‐
       tions to the command:

       any character
	      Replaces the character above.

       space or tab
	      Skips over the above character(s).

       #      Deletes one character.

       %      Replaces one character with a space.

       ^      Inserts the rest of the typed line just before the character.

       $      Deletes the rest	of  the	 line  from  that  character  on,  and
	      replaces it with the rest of the typed line.

       +      Appends the rest of the typed line.

       -      Backs up to a previous command satisfying the same matching con‐

       end of file
	      If an end-of-file is read from the keyboard by  the  editor,  it
	      aborts with exit status 1 and does not produce any output.

       The  history  programs  work best when their output is reinterpreted by
       the shell using an eval command.	 This can be  achieved	by  writing  a
       shell function to perform the reinterpretation:

	    fn - -- {
		 comm = `{$0^p $*}
		 if (! ~ $#comm 0) {
		      echo $comm >[1=2]
		      eval $comm

				 30 July 1991			    HISTORY(1)

List of man pages available for 4.4BSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net