Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know I can pushd / popd if I want to save the current location before chdir into another directory. In bash I can go back to the directory before the last chdir by:

$ chdir /somedir
$ chdir -

I'm wondering if I can go back for several steps (chdir ---- maybe??), just using chdir rather than pushd / popd, in bash is that possible?

share|improve this question
add comment

2 Answers

Did you know that pushd saves directories on a stack, so it can have multiple directories saved?

You can skip around using a command such as:

pushd +3; popd
share|improve this answer
1  
You can even use alias cd=pushd, to avoid having to type the extra characters in pushd. –  Chris Johnsen Dec 20 '09 at 6:15
    
Thanks, but pushd prints the annoying stack contents, and, BTW won't it be blown up if pushd too many times? –  Xiè Jìléi Jul 10 '10 at 8:29
add comment
up vote -1 down vote accepted

No, it's impossible.

share|improve this answer
    
You can always write a shell function wrapper around chdir that checks if the argument is multiple dashes and then calls popd, while dumping the stack contents to /dev/null. –  eldering Oct 28 '11 at 13:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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