sed — Stream Editor

Stream editing and text transformation with sed across 13 disciplines. Each discipline is a directory — add sub-pages as it grows without restructuring. All commands copy-paste-runnable on Arch Linux.

Disciplines

Discipline Description Partials

Basics

Pattern replacement, global/nth occurrence, backreferences, delimiters

1

Addressing

Line numbers, ranges, pattern ranges, step addressing, conditional substitution

1

Extraction

Capture groups, value extraction, IP parsing, YAML stripping, URL extraction

1

In-Place

Verify-before/change/verify-after, backups, diff preview, idempotent edits

1

Transforms

Append, insert, replace lines, join lines, read files into stream

1

Infrastructure

Bulk xref rename, config surgery, ANSI stripping, attribute transforms

1

Gotchas

macOS vs GNU, greedy matching, BRE vs ERE, hold buffer, quoting traps

1

Hold Buffer

Pattern space and hold space — h, H, g, G, x, reverse, swap, collect blocks

1

Multiline

Multi-line processing — N, P, D, join lines, paragraph mode, cross-line replace

1

Regex

BRE vs ERE, character classes, anchors, backreferences, IP/MAC/date matching

1

Branching

Flow control — labels, b, t, loops, :a;N;$!ba, script files, nth occurrence

1

Config Files

Real config surgery — sshd, pacman, systemd, INI, YAML, fstab, hosts, nginx, sysctl

1

Pipelines

Multi-tool chains — grep+sed, find+xargs+sed, sed+awk, process substitution, tee

1

See Also

  • awk — field processing (where sed operates on lines)

  • grep — pattern matching (sed’s read-only counterpart)

  • xargs — act on sed output

  • Regex Patterns — cross-tool regex reference