Hack 54. Execute previous command that starts with a specific word

by Ramesh

Type ! followed by the starting few letters of the command that you would like to re-execute. In the following example, typing !ps and enter, executed the previous command starting with ps, which is ‘ps aux | grep yp’.

  1. # !ps
  2. ps aux | grep yp
  3. root 16947 0.0 0.1 36516 1264 ? Sl 13:10 0:00 ypbind
  4. root 17503 0.0 0.0 4124 740 pts/0 S+ 19:19 0:00 grep yp