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.


Exit from a while, for, or do loop.

close( )



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.


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

cos( )


Return cosine of x in radians.


delete array[element]

Delete element of an array.

while (expr)

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


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( )


Return exponential of x (e ^ x).


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.