O'Reilly logo

Linux Shells by Example by Ellie Quigley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.1. Comparison Expressions

Comparison expressions match lines where the action is performed if the condition is true. These expressions use relational operators and are used to compare numbers or strings. Table 6.1 provides a list of the relational operators. The value of the expression is 1 if the expression evaluates true, and 0 if false.

6.1.1. Relational operators

Table 6.1. Relational Operators
Operator Meaning Example
< Less than x < y
<= Less than or equal to x <= y
== Equal to x == y
!= Not equal to x != y
>= Greater than or equal to x >= y
> Greater than x > y
~ Matched by regular expression x ~ /y/
!~ Not matched by regular expression x !~ /y/
Example 6.1.
(The Database)
% cat employees
						Tom Jones 4423 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required