Name
if
Synopsis
if ( condition )
command1
[else
command2]
Description
If condition is true, do command1; otherwise, do command2. Condition can be an expression using any of the relational operators <, <=, ==, !=, >=, or >, as well as the pattern-matching operator ~. A series of commands must be put within braces.
Example
The following lines determine whether the first word in each line starts with A, uppercase or lowercase:
if ($1 ~ /[Aa]*/)
...Begins with A or a
Get Linux in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.