Conditional statements such as if and switch are used to test expressions and control the flow of execution in AWK programs. All control statements start with special keywords such as if and switch to differentiate them from simple expressions. Within one conditional statement block, we can have other multiple statements separated by braces, newlines, or semicolons. Such conditional statements are known as compound statements.
Conditional statements
The if statement
if is a conditional statement used to control the flow of a program. AWK supports three types of if statements:
- if
- if...else
- if...elseif...elseif...