The UNIX shell maintains a record of recently issued commands and provides convenient means of reusing that information in forming new commands. This feature is known as ``history''. It allows you to repeat commands and to make minor corrections to commands.
To display the list of recent commands type:
% history
To repeat the nth command listed in the history:
% !n
For example, to execute the 8th command in this session type:
% !8
To repeat the last command type:
% !!
To repeat the last command that started with "pat" type:
% !pat
For example, if the most recent command that began with "n" was:
% nroff -ms sample
To repeat it just type:
% !n
To use the last argument of the previous command type:
!$
For example, if the previous command was:
% more ltr.application
The file ltr.application can be edited with:
% vi !$
To correct the previous command type:
% ^old^new
For example, if the previous command was:
% ni paper
It could be corrected to:
% vi paper
by typing:
% ^ni^vi
For more information about history, see the manual page for the C-shell by typing:
% man csh
Or, if the Bourne-Again shell is your preferred shell, type:
% man bash