awk(1)

awk(1)

an element of ARGV to null means that it will not be treated as an input ®le. The name - indicates the standard input. If an argument matches the format of an assignment operand, this argument will be treated as an assignment rather than a ®le argument.

ENVIRON Array of environment variables; subscripts are names. For example, if environment variable V=thing, ENVIRON["V"] produces thing.

RSTART The starting position of the string matched by the match function, numbering from 1. This is always equivalent to the return value of the match function.

RLENGTH

The length of the string matched by the match function.

Functions can be de®ned (at the position of a pattern-action statement) as follows:

function foo(a, b, c) { ...; return x }

Parameters are passed by value if scalar, and by reference if array name. Functions can be called recur- sively. Parameters are local to the function; all other variables are global.

Note that if pattern-action statements are used in an HP-UX command line as an argument to the awk command, the pattern-action statement must be enclosed in single quotes to protect it from the shell. For example, to print lines longer than 72 characters, the pattern-action statement as used in a script (-fprog®le command form) is:

length > 72

The same pattern action statement used as an argument to the awk command is quoted in this manner:

awk 'length > 72'

EXTERNAL INFLUENCES

Environment Variables

LANG Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables contains an invalid setting, awk will behave as if all internationalization variables are set to "C". See environ(5).

LC_ALL If set to a non-empty string value, overrides the values of all the other internationalization variables.

LC_CTYPE Determines the interpretation of text as single and/or multi-byte characters, the classi®cation of characters as printable, and the characters matched by character class expressions in regular expressions.

LC_NUMERIC Determines the radix character used when interpreting numeric input, performing conversion between numeric and string values and formatting numeric output. Regardless of locale, the period character (the decimal-point character of the POSIX locale) is the decimal-point character recognized in processing awk programs (including assignments in command-line arguments).

LC_COLLATE Determines the locale for the behavior of ranges, equivalence classes and multi-character collating elements within regular expressions.

LC_MESSAGES

Determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.

NLSPATH

Determines the location of message catalogues for the processing of LC_MESSAGES.

PATH

Determines the search path when looking for commands executed by system(cmd) , or

 

input and output pipes.

In addition, all environment variables will be visible via the awk variable ENVIRON.

International Code Set Support

Single- and multi-byte character code sets are supported except that variable names must contain only ASCII characters and regular expressions must contain only valid characters.

a

HP-UX Release 11i: December 2000

− 4 −

Section 137