How AWK Works

AWK = Aho, Weinberger, Kernighan

AWK Script

BEGIN { print "=== START ===" } { print NR ": " $1 " + " $2 " = " ($1 + $2) } END { print "=== END ===" }

Key Concepts

  • Line-by-line: AWK reads one record (line) at a time
  • Fields: $1, $2, $3... (split by whitespace or FS)
  • Built-ins: NR (line number), NF (fields count), $0 (whole line)
  • Pattern { Action }: If pattern matches → do action
  • BEGIN / END: Run before/after processing all lines

Input Data

10 20 5 15 30 7 12 8

Processing Animation

Output

Try editing the input data or script (in the browser dev tools) and re-run!
This is a simplified but accurate visualization of AWK's core loop.