GNU sed
$ gsed Foundation Med RiskGNU sed (gsed on macOS via Homebrew, sed on Linux) is the classic non-interactive stream editor for line-oriented regex extraction and replacement. Omitting -i previews transformations safely on stdout, whereas -i edits files in-place without an explicit --dry-run flag.
brew install gnu-sed Standard Unix stream transformation runs in sub-millisecond pipes; MCP adds zero benefit.
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
Non-interactive stream editor with -n line slicing and -E regex, but lacks --json, --dry-run (must omit -i), and suffers GNU vs BSD -i differences.
- Non-interactive
-n/-Estream editing - No
--json; GNU-isyntax differs from macOS BSDsed -i ''
Stdout mode is read-only, but -i overwrites files in-place without confirmation unless -i.bak is specified.
-imutates files directly;-i.bakpreserves a backup
Standard sed on Linux; brew install gnu-sed provides gsed on macOS.
- Universal Unix presence; macOS uses
gsedto distinguish from BSDsed
Lightweight line extraction (-n '1,50p') and stream filtering across every Unix host, though sd is cleaner for multi-file edits.
- Fast single-pass stream editing and line-range extraction
Foundational GNU Project utility maintained for decades under GPL-3.0-or-later.
- Official GNU Project package
Canonical GNU sed manual and comprehensive man page.
- Official manual at gnu.org/software/sed/manual
Security, Auth & Guardrails
None required; operates on local stdio streams and files.
100% free, offline, and open-source (GPL-3.0-or-later).
# GNU sed (gsed) Agent Rules - Always preview transformations by omitting `-i` (or piping to `diff`) before applying `-i` in-place. - Remember macOS stock `sed` requires `-i ''` while GNU `gsed` uses `-i` (no space/empty arg); use `-i.bak` or `gsed` for consistency.
Agent-Ready Command Recipes
Safe Read-Only Queries
gsed -n '10,40p' config.conf
Uses -n quiet mode and 10,40p to print lines 10–40 without altering config.conf.
gsed -E 's/http:\/\//https:\/\//g' config.conf
Omits -i so transformed output prints to stdout while config.conf stays untouched.
Controlled Writes & Previews
gsed -i.bak -E 's/old_host/new_host/g' config.conf
Updates config.conf in-place while saving a .bak backup file via -i.bak.
Strengths for Agents
- + Ubiquitous across Linux containers for
-n 'START,ENDp'line extraction and stream transforms. - + Omitting
-ilets agents verify exact transformed output on stdout first.
Caveats & Pitfalls
- ! GNU
sed -iand macOS BSDsed -i ''have incompatible in-place flag syntax. - ! Lacks
--jsonand multi-file.gitignore-aware traversal; prefersd -pfor project-wide edits.