MPE/iX Shell and Utilities Reference Manual, Vol 1

awk(1) MPE/iX Shell and Utilities awk(1)
Built-In Arithmetic Functions
atan2(expr1, expr2)
returns the arctangent of expr1/expr2 in the range of –π through π.
exp(expr), log(expr), sqrt(expr)
returns the exponential, natural logarithm, and square root of the numeric value of
expr. If you omit (expr), these functions use $0 instead.
int(expr)
returns the integer part of the numeric value of expr. If you omit (expr), the func-
tion returns the integer part of $0.
rand()
returns a random floating-point number in the range 0 through 1.
sin(expr), cos(expr)
returns the sine and cosine of the numeric value of expr (interpreted as an angle in
radians).
srand(expr)
sets the seed of the rand function to the integer value of expr. If you omit (expr),
awk uses the time of day as a default seed.
Built-In String Functions
n = gsub(regexp, repl, string)
works the same way as sub, except that gsub replaces all matching substrings (glo-
bal substitution).
pos = index(string, str)
returns the position of the first occurrence of str in string.Ifindex does not find str
in string, it returns zero.
len = length(expr)
returns the number of characters in the string value of expr. If you omit (expr), the
function uses $0 instead. The parentheses around expr are optional.
pos = match(string, regexp)
searches string for the first substring matching the regular expression regexp, and
returns an integer giving the position of this substring counting from one. If it finds
no such substring, match returns zero. This function also sets the built-in variable
RSTART to pos and the built-in variable RLENGTH to the length of the matched
string. If it does not find a match, match sets RSTART to zero and RLENGTH to -1.
You can enclose regexp in slashes or specify it as a string.
1-26 Commands and Utilities