UNIX for OpenVMS Users, Second 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 both Korn shell and OpenVMS use a different comparison operator for each.
| OpenVMS | |
|---|---|
| Example: | $! Equal to$ IF (l .EQ. 10) THEN$ IF (STRING .EQS. "Red") THEN |
| Example: | $! Not equal to$ IF (l .NE. 10) THEN$ IF (STRING .NES. "Red") THEN |
| Example: | $! Greater than 1 and less than 10$ IF (l .GT. 1 .AND. l .LT. 10) THEN |
| Example: | $! Equal to 0 or 1$ IF (l .EQ. 0 .OR. l .EQ. 1) THEN |
| Example: | $! Equal to Blue OR Red$ IF (STRING .EQS. "Blue" .OR. STRING .EQS. "Red") THEN |
| Example: | $! Not less than or equal to 10$ IF (.NOT. (l .LE. 10)) THEN |
| Example: | $! A zero-length (null) string$ IF (F$LENGTH(STRING) .EQ. 0) THEN$ IF (STRING .EQS. "") THENUNIX (C shell) |
| Example: | # equal toif ($i == 10) thenif ($string == "Red") then |
| Example: | # not equal toif ($i != 10) thenif ($string != "Red") then |
| Example: | # greater than 1 and less than 10if ($i>1 && $i<10) then |
| Example: | # equal to 0 or 1if ($i == 0 $i == 1) then |
| Example: | # equal to Blue or Redif... |