Indiana University
University Information Technology Services
  
What are archived documents?

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:

history

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 history

To 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:

!2

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:

r 2

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:

This is document abdj in domain all.
Last modified on August 22, 2008.
Please tell us, did you find the answer to your question?