logical operators
logical operators used in [] and test
|
logical operators used in [[]]
|
Description
|
-A
|
&&
|
And and, both ends are true, then true
|
-O
|
||
|
Or OR, at both ends there is a true and true
|
!
|
!
|
Not non, the opposite is true
|
Tips:
! Inverse: A logical value that is opposite to a logical value
-A Chinese meaning and (and &&): Two logical values are true, the return value is true, and the reverse is false
-O Chinese meaning yes or (or| | ): Two logical values if one is true, the return value is True
Example:
[[Email protected] ~]# [$a-eq 2-a $b-eq 2]&&echo 1| | echo 00[[email protected] ~]# [$a-eq 2-o $b-eq 2]&&echo 1| | Echo 0 1
Summary:
[] with-a,-o
[[]] with &,| |,!
Test usage and [] same
multiple [] and multiple [[]], or arbitrary or mediation logic operations are && or | |
This article is from the "Sandshell" blog, make sure to keep this source http://sandshell.blog.51cto.com/9055959/1964174
9-shell Logical operator Knowledge Introduction-Practice and Enterprise case script anatomy