Solaris Advanced User's Guide

Repeating Commands in the Korn Shell

If you use the Korn shell, type the following command to repeat the previous command.

$ fc -s -
Tue Oct 31 15:18:38 MST 2000

You can also repeat any previously typed command by typing fc -s x, where x is the desired command's corresponding number on the history list. To see the history list, type the fc -l command and press Return. The following example is a sample history list.

$ fc -l
344  pwd
345  clear
346  ls -l
347  cd $HOME
348  logname
349  date
350  history

You can also repeat commands from the history list by following the fc -s command with a negative number. For example, to repeat the second from the last command on the history list, type the following command.

$ fc -s -2
Tue Oct 31 15:20:41 MST 2000

Using the previous example history list, the date command repeats.

You can also use the fc -s command with the first few characters of a previous command. For example, if you had previously typed the date command to display the current date, you could type fc -s da to display the date again. 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 fc -s command, the system repeats the most recent command that begins with that letter.