The command repeating features described in this section are available only if you are using the C shell.
A quick way to repeat the last command you typed is to type !! and press Return. The system keeps a history of commands you type and is able to repeat previous commands. For example, if the last command you entered was date:
example% !! date Mon Feb 3 10:26:20 PST 1992 example% |
You can also repeat any previously typed command by typing !x, where x is the desired command's corresponding number on the history list. To see the history list, type the history command and press Return. The following is an example of what you might see:
example% history 1 pwd 2 clear 3 ls -l 4 cd /usr/home/worker 5 logname 6 date 7 history |
Another method for repeating characters from the history list is to follow the ! with a negative number. For example, to repeat the second from the last command on the history list, you would type the following:
example% !-2 logname hankw example% |
Using the example history list above, the logname command is repeated.
Still another method is to follow the ! with the first few characters of a previous command. For example, if you had previously entered the clear command to clear your screen, you could type !cl to clear your screen again. With this method for repeating commands, however, you must use enough characters for the desired command to be unique in the history list. If you use only one letter after the !, the system will repeat the most recent command beginning with that letter.