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
| Name | Type | Description |
|---|---|---|
| -F | option | field separator |
| PROGRAM | operand | awk program |
| FILE | operand | input 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