如何在linux系统中执行shell脚本

    xiaoxiao2021-03-25  126

    首先在命令行中用vi或者其他编辑器编写一个简单的shell脚本,命名为hello。内容如下所示:

    echo "hello,world"

    采用三种方式运行执行hello,如下所示

    第一种:修改hello的可执行权限,$ chmod 755 hello   //或者 chmod u+x hello

                                                                                 $ ./hello

    显示为:  hello,world!                 (注:$为系统命令提示符)

    第二种:直接使用shell命令sh或bash来执行,如下所示

    $ sh  hello

    hello,world

    $ bash hello

    hello,world

    第三种:使用bash内部命令 “source" 或” . ",如下所示

    $ source  hello

    hello,world

             或   $   .   hello

    hello,world

    转载请注明原文地址: https://ju.6miu.com/read-1529.html

    最新回复(0)