AnatomyOf

Anatomy of an AWK file

example.awk
1#!/usr/bin/awk -f
2# One-liners: the only language feature AWK really needs for its resume
3
4BEGIN { FS = ":"; users = 0 } # /etc/passwd walked so /bin/passwd could run
5
6$3 >= 1000 { users++; print "Human:", $1 } # UID 1000+ is probably a person
7
8END { print "Total humans:", users, "(NR was " NR " all along)" }
Awk is a powerful domain-specific language designed for text processing and data extraction, structured around a data-driven pattern-action framework.