...soul, as in software?

Rantings about life.

20090730

Thu, 30 Jul 2009

Where was I?

UNIX® shells maintain the previous working directory in the variable OLDPWD, so it is easy to jump back to where you were previously dwelling:

$ cd $OLDPWD

This is a bit cumbersome to type, so this shortcut is provided:

$ cd -

(My then-classmate Carlos told me about this back in '98).

Recently I learned that for commands other than 'cd', which is internal to the shell, ksh and bash provide a tilde expansion for this OLDPWD var, i.e.: ~-

$ cd /srv/media/doc/science/cs/biblia/oreilly/lang/perl
$ ls mastering*
mastering_perl.pdf
$ cd /this/other/place 
$ cp -a ~-/mastering_perl.pdf .    # et voilà !

posted at: 16:50 | path: | permanent link to this entry

Valid XHTML 1.1 Valid CSS! powered by blosxom Debian GNU/Linux VPS hosting by RimuHosting