shell编程--流程控制for,do-while,if-then,break,continue,case等
2.5 流程控制 2.5.1 if语法 1、语法格式 ifconditionthenstatements[elifconditionthenstatements...][elsestatements]fi 2、示例 #!/bin/bash read -p "please input your name:" NAME ###read命令用于从控制台读取输入数据 printf '%s\n' $NAME if [ $NAME = root ] ##注意if和后面的[]有间距 then echo "hello ${NAME},welcome!" elif [ $NAME = toto ] then echo "hello ${NAME},welcome!" else echo "SB,get out here!" fi 脚本内容截图: 3、判断条件 1/ 条件判断基本语法 [ condition ] (注意condition前后要有空格) #非空返回true,可使用$?验证(0为true,>1为false) [ itcast ] #空返回false [ ] 注意[ ]内部的=周...