Home Linux bashOS X
 OS X Books, Links

history

Command Line history.

SYNTAX
      history [-hTr] [n]

      history -S|-L|-M [filename] (+)

      history -c (+)

Options

   [-hTr] [n]  The  first  form	 prints the history event list.	 If n is given
	       only the n most recent events are printed or saved.   With  -h,
	       the  history list is printed without leading numbers.  If -T is
	       specified, timestamps are printed also in comment form.	 (This
	       can be used to produce files suitable for loading with 'history
	       -L' or 'source -h'.)  With -r, the order of  printing  is  most
	       recent first rather than oldest first.

   -S          With  -S,  the  second form saves the history list to filename.
	       If the first word of the savehist shell variable is  set	 to  a
	       number,	at most that many lines are saved.  If the second word
	       of savehist is set to `merge', the history list is merged  with
	       the  existing history file instead of replacing it (if there is
	       one) and sorted by time stamp.  (+) Merging is intended for  an
	       environment  like  the  X  Window System with several shells in
	       simultaneous use.  Currently it succeeds only when  the	shells
	       quit nicely one after another.

   -L|-M       With -L, the shell appends filename, which is presumably a his-
	       tory list saved by the -S option or the savehist mechanism,  to
	       the  history list.  -M is like -L, but the contents of filename
	       are merged into the history list and sorted by  timestamp.   In
	       either  case,  histfile	is  used  if filename is not given and
	       ~/.history is used if  histfile	is  unset.   `history  -L'  is
	       exactly	like  'source  -h'  except  that it does not require a
	       filename.

   -c	       The last form clears the history list.

Notes
Login shells do the equivalent of `history -L' on startup and, if savehist is set, `history -S' before exiting.

Because only ~/.tcshrc is normally sourced before ~/.history, histfile should be set in ~/.tcshrc rather than ~/.login. If histlit is set, the first and second forms print and save the literal (unexpanded) form of the history list.

Saving History
Ater executing a series of commands (a task) save them all with:

history > cmds.yyyymmdd

To see all the saved command sessions run:

find ~/ -name "cmds.*"

"In times of change, learners inherit the earth, while the learned find themselves equipped to deal with a world that no longer exists" - Eric Hoffer

Related commands:

complete - Edit a command completion [word/pattern/list]

Equivalent BASH command:

history
- Command Line history



Back to the Top

Simon Sheppard
SS64.com