Relational expressions are a special kind of expression that always
evaluate to 0 or 1, 0 if the relation is false and 1 if the relation is
true. These may appear in any legal expression. (POSIX `bc`

requires that relational expressions are used only in `if`

,
`while`

, and `for`

statements and that only one relational
test may be done in them.) The relational operators are

`expr1 < expr2`

- The result is 1 if expr1 is strictly less than expr2.
`expr1 <= expr2`

- The result is 1 if expr1 is less than or equal to expr2.
`expr1 > expr2`

- The result is 1 if expr1 is strictly greater than expr2.
`expr1 >= expr2`

- The result is 1 if expr1 is greater than or equal to expr2.
`expr1 == expr2`

- The result is 1 if expr1 is equal to expr2.
`expr1 != expr2`

- The result is 1 if expr1 is not equal to expr2.

Go to the first, previous, next, last section, table of contents.