Go to the first, previous, next, last section, table of contents.


User-defined Functions

Functions in awk are defined as follows:

function name(parameter list) { statements }

Actual parameters supplied in the function call are used to instantiate the formal parameters declared in the function. Arrays are passed by reference, other variables are passed by value.

If there are fewer arguments passed than there are names in parameter-list, the extra names are given the null string as their value. Extra names have the effect of local variables.

The open-parenthesis in a function call of a user-defined function must immediately follow the function name, without any intervening white space. This is to avoid a syntactic ambiguity with the concatenation operator.

The word func may be used in place of function (but not in POSIX awk).

Use the return statement to return a value from a function.

See section User-defined Functions.


Go to the first, previous, next, last section, table of contents.