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.

link|improve this question

55% accept rate
feedback

2 Answers

up vote 5 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

link|improve this answer
feedback

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 )
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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