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

a
awk(1) awk(1)
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.
DIAGNOSTICS
awk supports up to 199 fields (
$1, $2, ..., $199) per record.
EXAMPLES
Print lines longer than 72 characters:
length > 72
Print first two fields in opposite order:
{ print $2, $1 }
Same, with input fields separated by comma and/or blanks and tabs:
BEGIN { FS = ",[ \t]*|[ \t]+" }
{ print $2, $1 }
Add up first column, print sum and average:
{s+=$1}"
END { print "sum is", s, " average is", s/NR }
Print all lines between start/stop pairs:
/start/, /stop/
Simulate echo command (see echo(1)):
BEGIN { # Simulate echo(1)
for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
printf "\n"
exit }
AUTHOR
awk was developed by AT&T, IBM, OSF, and HP.
SEE ALSO
lex(1), sed(1).
A.V. Aho, B.W. Kernighan, P.J. Weinberger: The AWK Programming Language, Addison-Wesley, 1988.
STANDARDS CONFORMANCE
awk: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2
Section 146 Hewlett-Packard Company 5 HP-UX 11i Version 2: September 2004