首页 > 系统服务 > 详细

linux 执行shell脚本

时间:2017-06-18 18:43:43      阅读:254      评论:0      收藏:0      [点我收藏+]

1、创建shell脚本:/home/test.sh

cd /home/

vim tesh.sh   #linux不区分后缀,.sh 只是为了方便使用者;

test.sh 文件首行定义格式: #!/bin/bash  表示该文件是用bash shell来执行;

内容随便写,例如: fdisk -l | grep ‘Disk /dev/sda‘ | awk ‘{print $3}‘     #显示sda分区的大小

2、执行方式:

a、相对路径(需要给执行权限):  chmod u+x test.sh

cd /home

./test.sh 

b、 绝对路径下

/home/test.sh

c、 使用bash、sh来执行,不需要给执行权限

bash test.sh

sh test.sh 

 

linux 执行shell脚本

原文:http://www.cnblogs.com/xw1104/p/7044918.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!