shell-逻辑操作符
常用的逻辑操作符号
| 操作符 | 说明 |
|---|---|
| ! | 逻辑非 |
| -a | 逻辑与 |
| -o | 逻辑或 |
逻辑与判断:$x的值是否大于10,小于20
[root@centos8 ~]# x=17
[root@centos8 ~]# test $x -gt 10 -a $x -lt 20
[root@centos8 ~]# echo $?
0
逻辑或判断:$y大于90,或小于80
[root@centos8 ~]# x=101
[root@centos8 ~]# test $x -gt 90 -o $x -lt 80
[root@centos8 ~]# echo $?
0

浙公网安备 33010602011771号