[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.4 Control Statements in Actions
Control statements, such as if
, while
, and so on,
control the flow of execution in awk
programs. Most of awk
’s
control statements are patterned after similar statements in C.
All the control statements start with special keywords, such as if
and while
, to distinguish them from simple expressions.
Many control statements contain other statements. For example, the
if
statement contains another statement that may or may not be
executed. The contained statement is called the body.
To include more than one statement in the body, group them into a
single compound statement with curly braces, separating them with
newlines or semicolons.
7.4.1 The if -else Statement | Conditionally execute some awk
statements.
| |
7.4.2 The while Statement | Loop until some condition is satisfied. | |
7.4.3 The do -while Statement | Do specified action while looping until some condition is satisfied. | |
7.4.4 The for Statement | Another looping statement, that provides initialization and increment clauses. | |
7.4.5 The switch Statement | Switch/case evaluation for conditional execution of statements based on a value. | |
7.4.6 The break Statement | Immediately exit the innermost enclosing loop. | |
7.4.7 The continue Statement | Skip to the end of the innermost enclosing loop. | |
7.4.8 The next Statement | Stop processing the current input record. | |
7.4.9 Using gawk ’s nextfile Statement | Stop processing the current file. | |
7.4.10 The exit Statement | Stop execution of awk .
|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |