commands

awk — process records and fields

Executes pattern/action rules, with fields $1 onward and $0 as the full record. END runs after input. Tested with mawk; extensions differ across implementations. Zero on normal completion unless program selects other exit status; errors nonzero. Example assumes a fresh search-transform lab fixture.

Formal Syntax & Structure

linux syntaxlinux
awk [-F SEPARATOR] PROGRAM [FILE]...

Parameters & Attributes

NameTypeDescription
-Foptionfield separator
PROGRAMoperandawk program
FILEoperandinput file

Return Value

exit status and output

Executes pattern/action rules, with fields $1 onward and $0 as the full record. END runs after input. Tested with mawk; extensions differ across implementations. Zero on normal completion unless program selects other exit status; errors nonzero.

Working Example

Example Snippetlinux
awk -F: '{total += $2} END {print total + 0}' sales.txt
Linux Reference