Bash Tip

Written by on Dec 11 2007

Try this:

> ls -al drwxr-xr-x 23 steve steve 782 Dec 9 00:27 . drwxr-xr-x 39 steve steve 1326 Dec 11 21:21 drwxr-xr-x 11 steve steve 374 Dec 11 18:16 .svn ……. > !! drwxr-xr-x 23 steve steve 782 Dec 9 00:27 . drwxr-xr-x 39 steve steve 1326 Dec 11 21:21 drwxr-xr-x 11 steve steve 374 Dec 11 18:16 .svn ……. > ls -al drwxr-xr-x 23 steve steve 782 Dec 9 00:27 . drwxr-xr-x 39 steve steve 1326 Dec 11 21:21 drwxr-xr-x 11 steve steve 374 Dec 11 18:16 .svn ……. > ls !$ drwxr-xr-x 23 steve steve 782 Dec 9 00:27 . drwxr-xr-x 39 steve steve 1326 Dec 11 21:21 drwxr-xr-x 11 steve steve 374 Dec 11 18:16 .svn …….

 

So:

  • !! reruns the last command (very useful if you forget to put sudo in front: > sudo !!).
  • !$ gets the first param of the last command.
Meet
Steven

Hi I'm Steven,

I wrote the article you're reading... I lead the developers, write music, used to race motorcycles, and help clients find the right features to build on their product.

Get Blog Updates