|
Maybe you are confused by the fact that if you put a cd command into a file and then execute the file your working directory doesn't change.
This is because the script is executing in a subshell that inherits your current environment. When the script finishes any changes it made to its own environment are lost with it.
The answer is to execute the script within your current environment rather than in a subprocess. This is called sourcing the script due to the command "source" used to accomplish this in the csh. It's still called sourcing the script even though the syntax is simply to use a dot in ksh or bash.
So, if a file called script contains a cd command, then
. script
will change your current working directory.
|