判断语句 if
格式1
语法:
if 条件 ;then commond;fi
eg:
#!/bin/bash
a=5
if [ $a -gt 3 ]
then
echo "大于3"
fi
格式2
语法:
if 条件1;then commond1;else commond2;fi
eg:
#!/bin/bash
a=5
if [ $a -gt 3 ]
then
echo "大于3"
else
echo "不大于3"
fi
格式3
语法:
if 条件1;then commond1;elif 条件2;then commond2;else commond3;fi
eg:
#!/bin/bash
a=5
if [ $a -lt 3 ]
then
echo "a<3"
elif [ $a -gt 6 ]
then
echo "a>6"
else
echo "Out of the zone"
fi