【发布时间】:2012-05-01 14:57:26
【问题描述】:
可能重复:
Whats the difference between running a shell script as ./script.sh and sh script.sh
当您运行像./yourscript.sh 和sh yourscript.sh 这样的脚本时,这有什么区别?
【问题讨论】:
可能重复:
Whats the difference between running a shell script as ./script.sh and sh script.sh
当您运行像./yourscript.sh 和sh yourscript.sh 这样的脚本时,这有什么区别?
【问题讨论】:
运行脚本 ./yourscript.sh 时,该文件必须标记为可执行文件,并且您必须在脚本顶部声明您希望使用的 shell。例如:
#!/bin/sh
<your code here>
仅使用 sh yourscript.sh 时,不需要这些要求。
【讨论】: