码迷,mamicode.com
首页 > 系统相关 > 详细

如何编写shell脚本

时间:2017-11-05 13:54:05      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:目录   这一   bin   如何   声明   创建   脚本   bash   ogr   

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

 

  

如何编写shell脚本

标签:目录   这一   bin   如何   声明   创建   脚本   bash   ogr   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!