z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


User-defined functions

z/OS UNIX System Services User's Guide
SA23-2279-00

In an awk program, a function definition looks like this:
function name(argument-list) {
    statements
}
The argument-list is a list of one or more names (separated by commas) that represent argument values passed to the function. When an argument name is used in the statements of a function, it is replaced by a copy of the corresponding argument value.
For example, the following is a simple function that takes a single numeric argument N and returns a random integer between 1 and N (inclusive):
function random(N) {
    return (int(N * rand() + 1))
}

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014