$ pwd
/tmp/d1
$ dirs
/tmp/d1
$ pushd ../d2
/tmp/d2 /tmp/d1
$ popd
/tmp/d1
$ pwd
/tmp/d1
It seems that pushd
always pushes the current directory e.g. /tmp/d1
into the stack, although I run it as pushd ../d2
?
Note that: http://linux.101hacks.com/cd-command/dirs-pushd-popd/
The first directory of the dir command output is always the current directory and not the content from the stack.
pushd -n ../d2
is what you are looking for? – jimmij Oct 11 '14 at 22:34