Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .