bash - Ubuntu script language doesn't work as expect -
this question has answer here:
- why doesn't “cd” work in bash shell script? 27 answers
as beginner of bash
script, wrote simple script change directory. here source code:
#!/bin/bash set -x echo "---------------------start-----------" cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3
i save "start" in /root
folder. change property of file executable, , run below. problem execution command cd
doesn't work. did miss?
cocadas@cocadas-thinkpad-w540:~$ ./start + echo ---------------------start----------- ---------------------start----------- + cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3 cocadas@cocadas-thinkpad-w540:~$ cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3 cocadas@cocadas-thinkpad-w540:~/workspace/carnd/carnd-behavioral-cloning-p3$
your ./start
call creates sub shell. run source start
or . start
(.
abbreviation of source
) instead execute script directly in command line, not in nested container.
Comments
Post a Comment