如何编写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

 

  

posted @ 2017-11-05 13:21  高伟-林州  阅读(1563)  评论(0编辑  收藏  举报