To reissue and repeat a long command without retyping it on a Unix or Linux system, you can use the history
and !
commands.
The history
command displays a list of the most recently executed commands in the current shell. Each command is preceded by a number, which is called the command's "history number".
To repeat a command, you can use the !
command followed by the history number of the command you want to repeat.
For example, to repeat the most recently executed command, you can use the following command:
!-1Sourcwww:e.lautturi.com
To repeat the second-most recently executed command, you can use the following command:
!-2
You can also use the !
command followed by the first few characters of the command you want to repeat. For example, to repeat the last command that started with the characters mysql
, you can use the following command:
!mysql
This will repeat the last command that started with the characters mysql
.