awk

Powerful text processing language for pattern scanning and field-based reporting.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

awk processes text line-by-line, splitting each into fields ($1, $2, etc.) by a delimiter (default: whitespace). Supports conditionals, loops, and arithmetic — ideal for log analysis, report generation, and structured text extraction.

Common flags
FlagMeaning
-FSet field separator (-F: for colon-delimited files like /etc/passwd)
-vAssign a variable before program execution
-fRead awk program from a file
Examples
awk '{print $1, $NF}' access.logPrint first and last field from each line (e.g. IP and status code) · explain & risk-check →
awk -F: '$3 >= 1000 {print $1}' /etc/passwdList all usernames with UID >= 1000 (regular users) · explain & risk-check →
awk '/ERROR/{count++} END{print count}' app.logCount ERROR occurrences in a log file · explain & risk-check →
Pro tip

`awk 'NR==FNR{a[$0];next} $0 in a'` finds common lines between two files — a classic awk idiom for set intersection without sorting.

Related
sed grep cut sort uniq
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man awk for your version. Test destructive commands on a non-production system first.