歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> sh xxx.sh 與 ./xxx.sh 的區別?

sh xxx.sh 與 ./xxx.sh 的區別?

日期:2017/2/27 11:58:33   编辑:Linux文化

>>> 此貼的回復 >> 首先, ./file.sh 需要有 x permission, 而sh file.sh 不需要. 如果 file.sh 裡面有指定 interpreter (在第一行用 #!/path) 的話, 兩者都會用指定的 interpreter 作 sub shell 去執行 file.sh 裡面的命令. 但如果沒有指定 interpreter, 那 sh file.sh 則會用 sh 作 sub shell. 至於 ./file.sh , 那要看你當前的 shell 是甚麼類型的: 有的 shell 用當前的 shell 作 sub shell, 有些則指定預設的 shell 作 sub shell.

但無論如何, sub shell 的環境(如變量)是不會影響當前 shell 的.

Copyright © Linux教程網 All Rights Reserved