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à !
Tags
bash