Shell中if的格式:
if [ conditions ]
then
expr
elif [ conditions ]
then
expr
else
fi
[ conditions ] 包括
1. !,-a,-o
2. -n,-z, =,!=
3. -eq,-ge,-gt,-le,-lt,-ne
4. -ef,-nt,-ot
5. -b,-c,-d,-e,-f,-g,-G,-h, -k,-L,-O,-p,-r,-s,-S,-t,-u,-w,-x
类型1为逻辑判断 是、非、与或
[root@021Y-SH-BKAP ~]# if [ 1=1 -a 2=2 -o 2=3 ] ; then echo $? ;fi 0 这个逻辑就是同时满足1=1和2=2条件为真,或2=3条件为真,显然或前面已经满足,所以返回的结果为0
2