
自动化运维--编程--shell
沙漠蚂蚁--顽石
视频教程:网易云课堂搜索"顽石"
展开
-
shell--条件测试语句和流程控制语句的使用
1. test 判断 test $num1 == $num2 #判断是否相等 echo $? test $num != $num2 test $str #判断字符串是否非空,非空结果为0 test -z $str #判断字符串是否为空,为空结果为0原创 2016-04-14 17:36:29 · 472 阅读 · 0 评论 -
shell脚本的基本使用--bash
学习shell脚本主要是为了方便一部分的自动化运维,如一些软件的自动化的安装,避免反反复复的敲命令。 本文中使用的shell为bash。 1. 第一个shell脚本 touch test.sh #新建脚本文件 chmod u+x test.sh #添加执行权限 vim test.sh原创 2016-04-14 16:02:26 · 626 阅读 · 0 评论 -
shell--循环语句
1. case多条件语句 num=3 case $num in 1 2 3 1) echo "1" ;; 2) echo "2" ;;3) echo "3" ;;*) echo "other" ;;2原创 2016-04-14 18:40:23 · 447 阅读 · 0 评论 -
shell--shift左移参数、函数
1. shift左移参数 shift命令作用为每次左移一个参数,被移除的参数不可再用,无效。 test.sh : 参数求和 num=1 sum=0 while ((num do ((sum+=$1)) shift #参数左移一次 d原创 2016-04-14 19:31:50 · 953 阅读 · 0 评论