sed
Installation
SKILL.md
GNU sed Skill
All output assumes GNU sed (sed --version shows GNU). POSIX compatibility is
not a goal; use -E (extended regex) by default unless basic regex is clearly
sufficient.
Core Principles
- Prefer one-liners. Multi-line sed scripts are a last resort.
- Use
-Efor extended regex (avoids backslash noise). - Use
-ifor in-place edits; always show the command with a backup suffix suggestion (-i.bak) if the operation is destructive. - Dry-run first. When editing files, show the
sedwithout-ibefore the in-place version so the user can verify. - Chain with pipes when sed alone isn't the cleanest tool.
- Never use sed to parse structured formats (JSON, YAML, XML). Redirect to
jq,yq, orxmllintand say why.