UNIX for OpenVMS Users, Third Edition

Table 10.4 illustrates the comparison operators supported by the C and Korn shells. We will encounter numerous uses of comparison operators in subsequent examples. We now introduce the if statement, discussed in greater detail under flow control in Section 10.8, to show how comparison operators function. The C shell uses the same operator for both text and integer variables, whereas Perl, Korn shell, and OpenVMS use a different comparison operator for each.
| C Shell Operator | Bash and Korn Shell Operator | Perl | OpenVMS Equivalent | UNIX Meaning |
|---|---|---|---|---|
| == | == | == | .EQ. | Equal to (arithmetic) |
| == | = | eq | .EQS. | Equal to (string) |
| ! | ! | ! | .NOT. | Boolean "not" (negates other operators) |
| != | != | ! ne | .NE. .NES. | Not equal to (arithmetic and string |
| && | && | && | .AND. | Boolean "and" |
|
|
|
| .OR. | Boolean "or" |
| > | > | > gt | .GT. .GTS. | Greater than (arithmetic and string) |
| < | < | < lt | .LT. .LTS. | Less than (arithmetic and string) |
| >= | >= | >= ge | .GE. .GES. | Greater than or equal to (arithmetic and string) |
| <= | <= | <= le | .LE. .LES. | Less than or equal to (arithmetic and string) |
The Bash shell also permits == as a string comparison operator for equality. Perl also supports the keywords or, and, and not as alternatives to , &&, and not, respectively, although there are important contextual differences in how these operators are evaluated. See documentation on Perl for more details.
OpenVMS
Example:
$! Equal to$...