A conditional expression is used with the [[compound command to test attributes of files and to compare strings. Field splitting and file name generation are not performed on the words between [[ and ]]. Each expression can be constructed from one or more of the following unary or binary expressions:
The following obsolete arithmetic comparisons are also permitted:
exp1 -eq exp2 | True, if exp1 is equal to exp2. |
exp1 -ne exp2 | True, if exp1 is not equal to exp2. |
exp1 -lt exp2 | True, if exp1 is less than exp2. |
exp1 -gt exp2 | True, if exp1 is greater than exp2. |
exp1 -le exp2 | True, if exp1 is less than or equal to exp2. |
exp1 -ge exp2 | True, if exp1 is greater than or equal to exp2. |
In each of the above expressions, if file is of the form /dev/fd/n, where n is an integer, then the test is applied to the open file whose descriptor number is n.
A compound expression can be constructed from these primitives by using any of the following, listed in decreasing order of precedence.
(expression) | True, if expression is true. Used to group expressions. |
! expression | True if expression is false. |
expression1 && expression2 | True, if expression1 and expression2 are both true. |
expression1 || expression2 | True, if either expression1 or expression2 is true. |
18.118.2.225