我有一個名爲/用戶/ TCL /腳本/ gotoroot文件這個腳本:爲什麼更改目錄(cd)不能在此mac腳本中工作?
echo "hello"
cd/
echo "good bye"
但是當我運行它,我得到這個:
User:scripts tcl$ pwd
/Users/tcl/scripts
User:scripts tcl$ gotoroot
hello
good bye
User:scripts tcl$ pwd
/Users/tcl/scripts
User:scripts tcl$
的目錄並沒有改變,我不不知道爲什麼?它應該是/,而不是/ Users/tcl/scripts
明白了,謝謝。這是https://stackoverflow.com/questions/255414/why-doesnt-cd-work-in-a-bash-shell-script的副本。 – John
爲什麼不只是'echo'$ PWD「'並跳過額外的過程? –
@EricRenouf正確的瑣事將是「爲什麼不只是'pwd'並跳過回聲呢?」但你的也沒關係。 ;) –