一 字符串判断
二 实战
[root@localhost ~]# name=fengji
[root@localhost ~]# [ -z $name ] && echo yes || echo no
no
[root@localhost ~]# name=""
[root@localhost ~]# [ -z $name ] && echo yes || echo no
yes
[root@localhost ~]# aa=11
[root@localhost ~]# bb=22
[root@localhost ~]# [ "$aa" == "$bb" ] && echo yes || echo no
no
[root@localhost ~]# [ "$aa" -eq "$bb" ] && echo yes || echo no
no
[root@localhost ~]# aa=22
[root@localhost ~]# [ "$aa" -eq "$bb" ] && echo yes || echo no
yes
[root@localhost ~]# [ "$aa" == "$bb" ] && echo yes || echo no
yes
三 多重条件判断
四 实战
[root@localhost ~]# aa=22
[root@localhost ~]# [ -n "$aa" -a "$aa" -gt 33 ] && echo yes || echo no
no
[root@localhost ~]# [ -n "$aa" -a "$aa" -gt 3 ] && echo yes || echo no
yes