![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
shell
dream_heheda
不再追求完美,去追求进步
展开
-
shell 脚本 循环
while语法:while conditiondo commanddone3.1 while read 读取文件并处理文件 每次读取一行,每一行的内容使用IFS作为分隔符读文件默认情况下IFS是空格,如果需要使用其它的需要重新赋值 例如 IFS=: 参考while read读取文本内容例子 有如下文件10.1.1.11 root 12...原创 2020-03-25 22:56:42 · 921 阅读 · 0 评论 -
shell 脚本 if
1.exit n 命令和 $?:exit 命令 使shell退出,也就是 手动结束脚本运行 参数n表示带返回值n退出,调用环境就可以根据这个返回值判断 这个程序运行是否成功。exit 0: 表示在调用环境 使用$? 就会返回0。0一般代表正常参考Shell $?:获取函数返回值或者上一个命令的退出状态例如:如果两个脚本,脚本a 和 脚本b 。 在脚本b中调用脚本a,需要在脚本b...原创 2020-03-25 22:55:18 · 160 阅读 · 0 评论 -
shell 脚本
1.echo 输出Shell echo命令#echo 输出字符串[root@VM_0_8_centos lib]# echo "this is test"this is test#echo 输出变量 用$()符号[root@VM_0_8_centos lib]# echo "$(TZ=GMT-8 date +%Y-%m-%d+%H:%M:%S+%A)"2020-03-19+18:...原创 2020-03-25 17:57:39 · 172 阅读 · 0 评论