I'm trying to change directory in a called bash script. For this I tried to use cd
command. But after the script ends current directory is restoring to position before the script call. I also tried to change PATH
variable but it didn't show any effect too. Is there a way to do this?
When you execute a shell script a new shell is started for execution of this script. This shell won't affect its parent processes.
To execute a script in your current shell's context use the source
or .
commands:
. cd.sh
source cd.sh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.