Command Summary for awk

The following alphabetical list of statements and functions includes all that are available in POSIX awk, nawk, or gawk. See Chapter 11, for extensions available in different implementations.

atan2( )

atan2(y, x)

Returns the arctangent of y/x in radians.

break

Exit from a while, for, or do loop.

close( )

close(filename-expr)

close(command-expr)

In most implementations of awk, you can only have a limited number of files and/or pipes open simultaneously. Therefore, awk provides a close( ) function that allows you to close a file or a pipe. It takes as an argument the same expression that opened the pipe or file. This expression must be identical, character by character, to the one that opened the file or pipe—even whitespace is significant.

continue

Begin next iteration of while, for, or do loop.

cos( )

cos(x)

Return cosine of x in radians.

delete

delete array[element]

Delete element of an array.

do
do
    body
while (expr)

Looping statement. Execute statements in body then evaluate expr and if true, execute body again.

exit

exit [expr]

Exit from script, reading no new input. The END rule, if it exists, will be executed. An optional expr becomes awk’s return value.

exp( )

exp(x)

Return exponential of x (e ^ x).

for

for (init-expr; test-expr; incr-expr) statement

C-style looping construct. init-expr assigns the initial value of the counter variable. test-expr is a relational expression that is evaluated each time before executing the statement. When test-expr is false, the loop is exited. ...

Get sed & awk, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.