In Unix, how can I reissue a long command without retyping it?
In Unix, you can use the history command to
view a list of the commands that can be reissued. At the shell
prompt, enter:
You will then see a list of previous commands that you have entered. For example, you may see something like the following:
1 trn 2 mailx -s "Here's the Usenet file" jjones@foo.com < ucs.news 3 lynx 4 mv myfile.txt newfile.txt 5 trn 6 historyTo reissue a command in csh, tcsh, or
bash, enter ! (the exclamation
point) followed by the number of the command you would like to repeat.
For example, if you would like to reissue command number 2, you would enter:
If you are using ksh, enter r followed
by a space and the number of the command you would like to repeat. For
example, if you would like to reissue command number 2, you would
enter:
Either of the above methods will work in zsh.
If you are using bash or tcsh, you may be
able to scroll through the command history simply by using the up and
down arrow keys at the shell prompt. Once you have found the command
that you would like to reissue, press Enter to execute
it.
For more information, read the man page for your shell.
At Indiana University, to get support for personal or departmental Linux or Unix systems, see At IU, how do I get support for Linux or Unix?
Also see:
- In Unix, where can I get information on differences between the various shells?
- In Unix, what is the man command, and how do I use it to read manual pages?
- In Unix, what is chsh, and how do I use it to change my shell?
Last modified on August 22, 2008.






