Linux/bash: How to reissue a history command without retyping

In linux, there is a command named “history“, you can use it to list all historic command you typed before. if you issue a long command before and then you want to re-run this command again, if there is a good way that you do not need to retyping it and then can run it. see below ways.

You need to check the command number in the history recored and then passing “!“, such as, if you wan t to reissue “scp -r root@node1” command and checking the command line number in the history record(assuming the number is 11), then issue the following command:

​!11

If you wan to re-run the same last command again, issue:

!!

If you want to re-run the most recent command starting with word “scp“, issue the following comand:

!scp

done…

You might also like:

Sidebar



back to top