MPE/iX Shell and Utilities Reference Manual, Vol 1
awk(1) MPE/iX Shell and Utilities awk(1)
A function definition can appear in the place of a pattern {action} rule. The parameter-list
contains any number of normal (scalar) and array variables separated by commas. When you
call a function, awk passes scalar arguments by value, and array arguments by reference. The
names specified in the parameter-list are local to the function; all other names used in the
function are global. You can define local variables by adding them to the end of the parameter
list as long as no call to the function uses these extra parameters.
A function returns to its caller either when it performs the final statement in the function, or
when it reaches an explicit return statement. The return value, if any, is specified in the
return statement (see the Actions section).
Patterns
A pattern is a regular expression, a special pattern, a pattern range, or any arithmetic expres-
sion.
BEGIN is a special pattern used to label actions that awk performs before reading any input
records. END is a special pattern used to label actions that awk performs after reading all
input records.
You can give a pattern range as
pattern1,pattern2
This matches all lines from one that matches pattern1 to one that matches pattern2, inclusive.
If you omit a pattern, or if the numeric value of the pattern is non-zero (true), awk performs
the resulting action for the line.
Actions
An action is a series of statements terminated by semicolons, newlines, or closing braces. A
condition is any expression; awk considers a non-zero value true, and a zero value false. A
statement is one of the following or any series of statements enclosed in braces.
# expression statement, e.g. assignment
expression
# if statement
if (condition)
statement
[else
statement]
# while loop
while (condition)
statement
Commands and Utilities 1-29