GNU Awk (gawk)
$ gawk Foundation Low RiskGNU Awk (gawk) extends POSIX awk with true RFC 4180 CSV parsing (--csv in 5.3+), associative arrays, regex matching, FPAT field splitting, and in-place editing (-i inplace), making it ubiquitous for line-oriented text and log extraction.
brew install gawk Streams gigabyte-scale text logs and quoted CSVs (gawk --csv) in constant memory without loading files into agent context.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Deterministic non-interactive Unix stream filter, but has zero native JSON output, positional $1/$2 fragility, and shell-quoting pitfalls.
- Zero native JSON output
- Requires gawk >= 5.3 for
--csv; positional field indexing
Read-only stdout by default; -i inplace mutates files in place and system() can invoke subcommands if scripted.
- Stdout default; explicit
-i inplacefor in-place writes
Standard on most Linux distributions and via brew install gawk on macOS, though macOS default awk is BSD awk without --csv.
- Preinstalled on many Linux systems;
brew install gawkon macOS
Unmatched streaming speed on unstructured logs, though mlr and duckdb are much safer and cleaner for headered CSV/JSON.
- Constant-memory streaming text & CSV processing
Long-standing GNU Project core tool maintained by Arnold Robbins under GPL-3.0.
- Official GNU Project tool
Exhaustive GNU Texinfo manual, though gawk vs POSIX/BSD awk flag differences trip up agents.
- Official GNU Awk manual at gnu.org/software/gawk/manual
Security, Auth & Guardrails
None; operates purely on local text files and stdin/stdout.
GPL-3.0 open-source GNU utility; completely free.
# GNU Awk (gawk) Agent Rules - Check `gawk --version` before using `--csv` (requires GNU Awk >= 5.3; macOS system `awk` is BSD awk). - Avoid `-i inplace` until you have tested the program on stdout. - Prefer `mlr` or `duckdb` when JSON output or header-name indexing is needed.
Agent-Ready Command Recipes
Safe Read-Only Queries
gawk --csv 'NR<=20 {print $1, $3}' data.csv Parses quoted CSV fields properly via --csv and prints columns 1 and 3 for the first 20 rows.
gawk -F'\t' '{counts[$2]++} END {for (k in counts) print k, counts[k]}' events.tsv Computes grouped frequencies across tab-delimited rows in a single streaming pass.
Controlled Writes & Previews
gawk '$3 > 500 {print}' metrics.txt > high_latency.txt Writes matching records to high_latency.txt without modifying the original input via -i inplace.
Strengths for Agents
- +
--csvin GNU Awk 5.3+ finally handles quoted/multiline CSV fields accurately. - + Streams multi-GB text logs in constant memory with sub-millisecond startup.
Caveats & Pitfalls
- ! No native JSON output; hand-formatting JSON inside
awkprintfeasily breaks escaping. - ! macOS ships BSD
awkby default, which lacks--csv,FPAT, and-i inplace.