HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

a
awk(1) awk(1)
The arguments in ARGV can be modified or added to;
ARGC can be altered. As
each input file ends,
awk will treat the next non-null element of
ARGV, up to the
current value of
ARGC-1, inclusive, as the name of the next input file. Thus, setting
an element of ARGV to null means that it will not be treated as an input file. 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
file argument.
ENVIRON Array of environment variables; subscripts are names. For example, if environ-
ment 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 defined (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 (
-f
progfile 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
UNIX95 If defined, specifies to use the XPG4 behavior for this command. The changes for XPG4
include support for the entire behavior specified above and include the following behavioral
change:
If CONVFMT is not specified and UNIX95 is set, %d is used as the internal conversion
format for numbers by default.
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 interna-
tionalization variables contains an invalid setting, awk will behave as if all internationali-
zation 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
classification 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 conver-
sion 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.
HP-UX 11i Version 1: September 2005 4 Hewlett-Packard Company Section 137