awk.1 (2010 09)
a
awk(1) awk(1)
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 }
WARNINGS
If the input line length to awk is greater than 3,000 bytes, then the behaviour is undefined.
AUTHOR
awk was developed by AT&T, IBM, OSF, and HP.
SEE ALSO
lex(1), sed(1), standards(5).
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
HP-UX 11i Version 3: September 2010 − 5 − Hewlett-Packard Company 5