私は/ユーザ/ TCL /スクリプト/ gotorootというファイルにこのスクリプトを持っている:なぜこのdir(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$
ディレクトリを変更し、Iドンれていませんどうして?これは、/ Users/tcl/scriptsではないはずです。
ありがとうございました。これはhttps://stackoverflow.com/questions/255414/why-doesnt-cd-work-in-a-bash-shell-scriptの複製です。 – John
なぜ 'echo '$ PWD" 'を実行して余分なプロセスをスキップするのですか? –
@EricRenouf正しいpedantryは "pwdだけでなく、エコーをスキップするのはなぜですか?"あなたも大丈夫です。 ;) –