如何编写shell脚本

1.首先创建一个目录

    vi hello.sh

2.编写shell第一行

    #!/bin/bash    (为了声明是shell脚本,第一行都要这么写)

3.可以添加注释

    #the first program (加#的这一行是不生效的)

4.写脚本

    echo "hello world"

5.执行脚本,

   赋予执行权限: chmod u+x hello.sh   或 chmod 755 hello.sh

   执行脚本: ./hello.sh

或者  直接 bash hello.sh

  

原文地址:https://www.cnblogs.com/gw666/p/7787215.html