0

This question already has an answer here:

Say I do the following:

cd ~
pushd .
cd /bin/
pushd .
dirs
"/bin/ ~/
cd ~/Downloads/
pushd .
dirs
~/Downloads /bin/ ~"

How would I popd back to something a while ago, say from downloads to the home directory~?

marked as duplicate by Ulrich Dangel, jasonwryan, cuonglm, Ramesh, Anthon Jul 2 '14 at 5:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • So what would I do popd 2 to go to something that I pushd'd two times ago? – user73959 Jul 2 '14 at 2:27
0

Depending on your shell, for zsh you can just use cd -N to change to your Nth previous directory.

For bash you can use for example dirs to get a directory name. You can use that to do something like cd "$(dirs -N)" which will go the the Nth previous directory, just like the zsh example above.

Not the answer you're looking for? Browse other questions tagged or ask your own question.