#print date 单行注释
date 程序主题
: "
1.print date 多行注释(:与"之间有个空格)
2.
2.
"
date 程序主题
当脚本没有可执行权限时,是不能用脚本的绝对路径去调用他的
相对路径也不行
调用的三种方法
##1 source xx.sh
[root@huang4 script]# source hh.sh
Tue May 27 05:45:00 PM CST 2025
##2 . xx.sh
[root@huang4 script]# . hh.sh
Tue May 27 05:45:25 PM CST 2025
##3 sh xx.sh
[root@huang4 script]# sh hh.sh
Tue May 27 05:45:33 PM CST 2025
## 添加权限
[root@huang4 script]# chmod +x hh.sh
“ source hh.sh ”与“ . hh.sh ”:以当前的shell作为解释器,不会开启新的shell
“ sh hh.sh ”:用指定的解释器
“ ./hh.sh ”:在脚本文件中查看使用哪一种解释器,先开发后运行
显示执行过程
## 调试脚本 sh -x name.sh
## +表示动作 没有+表示输出
[root@huang4 script]# sh -x hh.sh
+ date
Thu May 29 10:56:20 PM CST 2025
直接执行脚本
[root@huang4 script]# sh hh.sh
Thu May 29 10:58:36 PM CST 2025
执行一条命令完毕后,系统会给出一个退出值,若成功则为0,出现错误则1~255
退出状态码是一个整数,其有效范围为0~255
行为良好的UNIX命令,程序和工具都会返回0作为退出码来表示成功。
Copyright © 2019- zgxue.com 版权所有 京ICP备2021021884号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务