Linux: Execute a Specific Command from History
If you would like to repeat a command from the history list, use the following technique:

First, bring up the history by using the history command:

# history | more
1  service network restart
2  exit
3  id
4  cat /etc/redhat-release

Now, from this history list, choose the command to repeat and place a ! before it. For instance:

# !1
service network restart
Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Setting network parameters: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ]

Post By Editor (2,827 Posts)

Website: →