Appendix A: Awk Reference Manual

This appendix explains, with examples, the constructs that make up Awk programs. Because it’s a description of the complete language, the material is detailed, so we recommend that you skim it, then come back as necessary to check your understanding.

The first section describes patterns. The second section deals with actions: expressions, assignments, and control-flow statements. The remaining sections cover function definitions, output, input, and how Awk programs can call other programs.

Awk programs. The simplest Awk program is a sequence of pattern-action statements:

pattern { action }
pattern { action }
...

In some statements, the pattern may be missing; in others, the action and its enclosing braces may ...

Get The AWK Programming Language, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.