Go to the previous, next section.
The UNIX C shell provides a mechanism that allows you to recall
previous commands and re-execute them. To see what commands UNIX
has saved during your login, use the history
command.
UNIX responds with a display similar to the following:
1 mail 2 finger 3 cd assign1 4 ls -F 5 more try1.c 6 grep bitsearch try1.c 7 cd 8 ls *.h 9 cp myheader.h assign1 10 pwd 11 cd assign1 12 vi try1.c 13 cc -o try1 try1.c 14 lint try1.c
Knowing which commands you've entered, you can re-execute any of them using one of several methods. You can re-execute the most recent command, you can re-execute a command by specifying its number or a fragment of its name, or you can add to a command and then re-execute it.
There are also more sophisticated methods for re-executing pieces of
previous commands. They are described in section The C shell and in the
csh
man page. In general, program development time can be
decreased simply by re-executing compile and edit commands.
To re-execute the last command you entered, type !!. The following example shows this command and how UNIX responds:
rigel% !! lint try1.c output from lint
To re-execute a command by specifying its number,
type !number where number is the
command number. For example (look at the history
example
above)
rigel% !8 ls *.h
To re-execute a command by specifying its name or a fragment of its name, type !name where name is the name or name fragment. For instance:
rigel% !more more try1.c
To add to a command and then re-execute it, use one of the preceding methods but don't type a carriage return, and then, on the same command line, type what you want to add to the command. The following example shows the lint command being re-executed with "| less" added to it:
rigel% !lint | less lint try1.c | less
For even faster program development, combine history with job control. See section Controlling Jobs, for more info.
Go to the previous, next section.