1.if语句的格式 if condition如果 then那么 elif又如果 then那么 。。。如果那么可以有任意多次 else否则(可加可不加) fi结束 注意:当if语句的条件和then在一行时,必须又有分号,否则会出错 2.if语句的实例 #!/bin/bash read n1 read n2 if (($n1==$n2)) then echo "$n1和n2相等" else echo "$n1和n2相等" fi 输出结果:sh 01.sh 1 2 1和2不相等