UNIX for OpenVMS Users, Third Edition

10.5: Comparison Operators

10.5 Comparison Operators

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.

Table 10.4: Comparison Operators

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$...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Measurement While Drilling (MWD) Systems
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.