Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

GNU Awk (gawk)

$ gawk Foundation Low Risk
GNU Project · Database & Data · GPL-3.0 · macos / linux / windows

GNU 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.

FCRS-1.0 Score
76 /100
Good
Medium Confidence
Zero-Friction Install
brew install gawk
CLI vs MCP Decision CLI Only

Streams gigabyte-scale text logs and quoted CSVs (gawk --csv) in constant memory without loading files into agent context.

Agent-Readiness Checklist

— JSON Output
✓ Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 16 / 25

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
Trust & Safety 22 / 25

Read-only stdout by default; -i inplace mutates files in place and system() can invoke subcommands if scripted.

  • Stdout default; explicit -i inplace for in-place writes
Setup & Portability 14 / 15

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 gawk on macOS
Utility & Efficiency 11 / 15

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
Maintenance & Lineage 7 / 10

Long-standing GNU Project core tool maintained by Arnold Robbins under GPL-3.0.

  • Official GNU Project tool
Docs & Verifiability 6 / 10

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

Auth Modes
No Auth
Credential Storage

None; operates purely on local text files and stdin/stdout.

Side Effects
Read-Only Local Write
Cost & Quotas

GPL-3.0 open-source GNU utility; completely free.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

Select quoted CSV columns using gawk 5.3+ --csv
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.

Aggregate counts by field from a delimited log
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

Filter lines into a new output file
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

  • + --csv in 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 awk printf easily breaks escaping.
  • ! macOS ships BSD awk by default, which lacks --csv, FPAT, and -i inplace.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI