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

GNU grep

$ grep Foundation Low Risk
GNU · Files & Search · GPL-3.0-or-later · macos / linux / windows

GNU grep is the canonical Unix pattern matcher supporting basic, extended (-E), fixed-string (-F), and Perl-compatible (-P) regexes with recursive --include/--exclude-dir filters. It is ubiquitous in Linux and CI environments, though it emits plain text rather than JSON.

FCRS-1.0 Score
85 /100
Good
High Confidence
Zero-Friction Install
brew install grep
CLI vs MCP Decision CLI Only

Standard POSIX/GNU text search executes directly in sub-millisecond pipes; MCP adds zero value here.

Agent-Readiness Checklist

Local Probe Evidence
— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
✓ Read-Only Mode
✓ NO_COLOR Clean
— Self-Describing
— Official SKILL.md
Version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
Startup
2 ms
Exit Codes (help / invalid)
2 / 2
NO_COLOR Clean / Non-TTY Safe
Yes / Safe
Captured --help excerpt
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 17 / 25

Deterministic non-interactive pipe tool with --color=never and exit codes (0 match, 1 none, 2 error), but lacks --json and .gitignore awareness.

  • Supports -n, -H, --color=never, and -m <num> match limits
  • Plain-text line output only; no --json flag
Trust & Safety 24 / 25

Strictly read-only line matcher with zero file mutation capabilities.

  • Read-only tool operating on files and stdin
Setup & Portability 13 / 15

Preinstalled on virtually every Linux container; brew install grep provides ggrep on macOS alongside stock BSD grep.

  • Universal Unix tool; minor BSD vs GNU flag differences (-P) exist on macOS
Utility & Efficiency 12 / 15

Reliable baseline text search across every Unix host and pipeline when rg is unavailable.

  • Supports -F, -E, -P, -m, and --include/--exclude-dir
Maintenance & Lineage 10 / 10

Foundational GNU Project utility maintained for decades under GPL-3.0-or-later.

  • Official GNU Project package
Docs & Verifiability 9 / 10

Canonical GNU manual and man grep documentation.

  • Official manual at gnu.org/software/grep/manual

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

None required; read-only text stream and file search.

Side Effects
Read-Only
Cost & Quotas

100% free, offline, and open-source (GPL-3.0-or-later).

Copyable Guardrail for CLAUDE.md / AGENTS.md
# GNU grep Agent Rules
- Always pass `--exclude-dir=.git --exclude-dir=node_modules` when running recursive `grep -r`.
- Note macOS stock `grep` is BSD `grep` (`-P` fails unless `ggrep` from `brew install grep` is used); prefer `-F` or `-E` for portability.

Agent-Ready Command Recipes

Safe Read-Only Queries

Recursive fixed-string search in TypeScript files
grep -rnF --color=never --exclude-dir=node_modules --include='*.ts' "fetchToken" src/

Searches literally (-F) with line numbers (-n), skipping node_modules and disabling ANSI color.

Extended regex search across log files
grep -rnE --color=never "ERROR|FATAL" logs/

Uses POSIX extended regex (-E) to extract error lines cleanly from logs.

Strengths for Agents

  • + Universally available on Linux servers, containers, and CI runners.
  • + -F fixed-string mode avoids regex escaping bugs, and -m caps match output.

Caveats & Pitfalls

  • ! Does not respect .gitignore or skip node_modules/.git unless --exclude-dir is passed.
  • ! GNU-only -P (PCRE) is unavailable in macOS stock BSD grep (requires ggrep).

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI