3 ms·
You can use "cd -" to go back to the previous directory.
by Cerium 9y ago
You can use "cd -" to go back to the previous directory.
- lyk 9y ago$OLDPWD also holds the previous directory.
- gabcoh 9y agoDoes that work like a stack or does it just swap?
- kbp 9y agoIt only swaps; you can use pushd and popd if you want a stack.
- kazinator 9y agoAlso: - "cd -" has no interaction with the pushd/popd stack except in the sense that it alters the top of the stack (the current working dir). It doesn't swap the two top entries of the directory stack, but swaps the top with an off-stack saved location ($OLDPWD). - "pushd" with no arguments swaps the top two stack entries.
- kazinator 9y agoIf you use "mkdir -", bash will not change into this directory. Not even if you use "cd -- -". "cd ./-" works.