I know I can use cd
command to change my working directory in bash.
But if I do this command:
cd SOME_PATH && run_some_command
Then the working directory will be changed permanently. Is there some way to change the working directory just temporarily like this?
PWD=SOME_PATH run_some_command
This question is related to
bash
shell
terminal
working-directory
bash has a builtin
pushd SOME_PATH
run_stuff
...
...
popd
Something like this should work:
sh -c 'cd /tmp && exec pwd'
Source: Stackoverflow.com