September 10, 2007

Neat shell tricks

First, I really enjoyed Andy Libby’s post about some of his favorite command line tricks. Great stuff!

It also got me hunting for some new tricks. Here’s what I’ve found so far:

  1. Substitution with ‘^’
    $ /etc/init.d/httpd stop
    $ ^stop^start  #executes /etc/init.d/httpd start
    
  2. Using CDPATH to get at common directories
    $ export CDPATH="/usr"
    $ cd bin  # goes to /usr/bin regardless of pwd