Examples of running a command from the history list

To re-run the previous command:

   history
      1  pwd
      2  cp memo.txt /tmp
      3  cd
      4  history
   !!
      1  pwd
      2  cp memo.txt /tmp
      3  cd
      4  history
      5  history

The history command is used to list the command history. Then the previous command is reexecuted, listing the command history again!


To re-run a specific command:

   !3
   cd

This re-runs command number three (3) in the command history.


To re-run the most recent command that starts with a particular character string:

   !pw
   pwd
   /home/grace

This re-runs the command pwd.


To re-run the most recent command that contains a particular character string:

   !?st
   history

This re-runs the history command.


[Home] [Search] [Index] This site maintained by webmaster@cs.auckland.ac.nz