【问题标题】:What is differences between ./yourscript.sh and sh yourscript.sh [duplicate]./yourscript.sh 和 sh yourscript.sh 有什么区别 [重复]
【发布时间】:2012-05-01 14:57:26
【问题描述】:

可能重复:
Whats the difference between running a shell script as ./script.sh and sh script.sh

当您运行像./yourscript.shsh yourscript.sh 这样的脚本时,这有什么区别?

【问题讨论】:

    标签: linux shell


    【解决方案1】:

    运行脚本 ./yourscript.sh 时,该文件必须标记为可执行文件,并且您必须在脚本顶部声明您希望使用的 shell。例如:

    #!/bin/sh
    <your code here>
    

    仅使用 sh yourscript.sh 时,不需要这些要求。

    【讨论】:

    • 需要还是不需要?祝大家好运。
    猜你喜欢
    • 1970-01-01
    • 2014-04-30
    • 2012-11-27
    • 2017-02-17
    • 2011-09-27
    • 2013-04-22
    • 2012-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多