Hack 53. Execute a specific command from history

by Ramesh

In the following example, If you want to repeat the command #4, execute !4 as shown below.

  1. # history | more
  2. 1 service network restart
  3. 2 exit
  4. 3 id
  5. 4 cat /etc/redhat-release
  6.  
  7. # !4
  8. cat /etc/redhat-release
  9. Fedora release 9 (Sulphur)