4 ms·
As it wasn't mentioned yet: pushd / popd These two commands replace 'cd' and work with a directory stack of different paths. $ pushd tmp # cd to tmp and
by etoulas 13y ago
As it wasn't mentioned yet: pushd / popd
These two commands replace 'cd' and work with a directory stack of different paths.
$ pushd tmp # cd to tmp and remember current path /
/tmp /
$ pwd
/tmp
$ cd /usr # normal cd to wherever you want...
$ pwd
/usr
$ popd # pop the stck and get back to the previous path
/
$ pwd
/
Subsequent pushd will stack multiple paths.
It's a built-in of bash and other shells. It works even with Windows' cmd.exe
- nightwolf 13y agoYou can also use "cd -" to go back to the previous path: $ cd / $ pwd / $ cd /tmp $ pwd /tmp $ cd - $ pwd / Not the same, of course, but still useful, I think.