sedlisted
Install: claude install-skill bastos/skills
# 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
1. **Prefer one-liners.** Multi-line sed scripts are a last resort.
2. **Use `-E`** for extended regex (avoids backslash noise).
3. **Use `-i` for in-place edits**; always show the command with a backup suffix
suggestion (`-i.bak`) if the operation is destructive.
4. **Dry-run first.** When editing files, show the `sed` without `-i` before the
in-place version so the user can verify.
5. **Chain with pipes** when sed alone isn't the cleanest tool.
6. **Never use sed to parse structured formats** (JSON, YAML, XML). Redirect to
`jq`, `yq`, or `xmllint` and say why.
---
## Flags to Always Know
| Flag | Meaning |
|--------------|--------------------------------------------------|
| `-E` | Extended regex (ERE): `+`, `?`, `|`, `()` work without backslash |
| `-i[SUFFIX]` | Edit in place (GNU: `-i` or `-i''` for no backup, `-i.bak` for backup) |
| `-n` | Suppress automatic print; use with `p` to print selectively |
| `-e` | Multiple expressions in one invocation |
| `-f FILE` | Read commands from a script file |
| `--sandbox` | Disallow `e`, `r`, `w` commands (safe mode) |
---
## Command Quick Reference
### Substitution (`s`)
```bash
# Basic replace