| Lesson 4 || Displaying previous commands |
| Objective || Use the history feature to display previous commands. |
Displaying Previous Unix Commands
The previous two lessons described how aliases make the command line easier to use.
The C shell provides another timesaving feature called command history, or sometimes just history.
The history feature lets you view previously entered commands, rerun them, or run modified versions of them. Before you can work with previously entered commands, you must define the C shell’s history variable, which tells the shell to start remembering the commands you enter.
The general syntax is: For example, to keep track of the 50 most recent commands, enter this:
% set history=n
% set history=50
From now on, the C shell will keep a record of commands you enter, up to 50. To display your previously entered commands, enter the following:
The following Slide Show shows how command history works:
If the history output scrolls beyond your screen, you can use the more program to pause the output. The command to use is this: history | more.
Command history is a C shell feature that lets you display previously entered commands, rerun them, or run modified versions of them.
In the next lesson, history substitution to repeat previous commands will be discussed.