Logical Operators

Table 10-5. Logical Operators

ExampleNameResult
$a and $bAndTrue if both $a and $b are true.
$a or $bOrTrue if either $a or $b is true.
$a xor $bOrTrue if either $a or $b is true, but not both.
! $aNotTrue if $a is not true.
$a && $bAndTrue if both $a and $b are true.
$a || $bOrTrue if either $a or $b is true.

The reason for the two different variations of "and" and "or" operators is that they operate at different precedences. (See Operator Precedence.)