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.

With bash is there a way to push and pop the current working directory? I tried writing bash;cd dir; ./dostuff;exit; but the current directory is now dir.

share|improve this question

2 Answers 2

up vote 14 down vote accepted

There is pushd and popd

Bash will keep a history of the directories you visit, you just have to ask. Bash stores the history in a stack and uses the commands pushd and popd to manage the stack.

More to read

share|improve this answer

Calling bash starts a new subshell, which has its own input; none of the other commands will run until it exits. Surrounding the commands to be run with parens will also start a new subshell, but it will run the commands within it.

( cd dir ; ./dostuff )
share|improve this answer

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.