Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
a
awk(1) awk(1)
The print statement prints its arguments on the standard output (or on a file if >file or >>file is present
or on a pipe if |cmd is present), separated by the current output field separator, and terminated by the out-
put record separator. file and cmd can be literal names or parenthesized expressions. Identical string
values in different statements denote the same open file. The printf statement formats its expression
list according to the format (see printf(3)).
Built-In Functions
The built-in function close(expr) closes the file or pipe expr opened by a print or printf state-
ment or a call to getline with the same string-valued expr. This function returns zero if successful, oth-
erwise, it returns non-zero.
The customary functions exp, log, sqrt, sin, cos, atan2 are built in. Other built-in functions are:
blength [( [s]) ]
Length of its associated argument (in bytes) taken as a string, or of $0 if no argu-
ment.
length [([s]) ] Length of its associated argument (in characters) taken as a string, or of $0 if no
argument.
rand() Returns a random number between zero and one.
srand( [expr]) Sets the seed value for rand, and returns the previous seed value. If no argument is
given, the time of day is used as the seed value; otherwise, expr is used.
int(x) Truncates to an integer value
substr(s, m [, n])
Return the at most n-character substring of s that begins at position m, numbering
from 1. If n is omitted, the substring is limited by the length of string s.
index( s, t ) Return the position, in characters, numbering from 1, in string s where string t first
occurs, or zero if it does not occur at all.
match( s, ere ) Return the position, in characters, numbering from 1, in string s where the extended
regular expression ere occurs, or 0 if it does not. The variables
RSTART and
RLENGTH are set to the position and length of the matched string.
split( s, a[, fs])
Splits the string s into array elements a[1], a[2], ..., a[n]
, and returns n. The
separation is done with the regular expression fs, or with the field separator
FS if fs
is not given.
sub( ere, repl [, in])
Substitutes repl for the first occurrence of the extended regular expression ere in the
string in.Ifin is not given, $0 is used.
gsub Same as sub except that all occurrences of the regular expression are replaced;
sub and gsub return the number of replacements.
sprintf( fmt, expr, ... )
String resulting from formatting expr ... according to the printf(3S) format fmt
system(cmd) Executes cmd and returns its exit status
toupper(s) Converts the argument string s to uppercase and returns the result.
tolower(s) Converts the argument string s to lowercase and returns the result.
The built-in function getline sets $0 to the next input record from the current input file;
getline <
file sets $0 to the next record from file. getline x sets variable x instead. Finally, cmd | getline
pipes the output of cmd into getline; each call of getline returns the next line of output from cmd.
In all cases, getline returns 1 for a successful input, 0 for end of file, and −1 for an error.
Patterns
Patterns are arbitrary Boolean combinations (with !||&&) of regular expressions and relational expres-
sions. awk supports Extended Regular Expressions as described in regexp(5). Isolated regular expres-
sions in a pattern apply to the entire line. Regular expressions can also occur in relational expressions,
using the operators ˜ and !˜. /re/ is a constant regular expression; any string (constant or variable) can
be used as a regular expression, except in the position of an isolated regular expression in a pattern.
HP-UX Release 11i: December 2000 − 2 − Section 1−−35
___
___