Everyone knows sed can find and replace, and almost nobody remembers exactly how - the delimiters, the escaping, the flag differences between platforms. sd is the tool for the 90 percent case. It's a simple find-and-replace CLI: you give it a pattern and a replacement, it uses a modern regex syntax that behaves the way you expect, and it can operate on stdin or edit files in place, with none of sed's ceremony.
Replace, the Obvious Way
The interface is just: what to find, what to replace it with:
# Replace in a stream
echo 'hello world' | sd world there
# Edit files in place
sd 'foo\(\d+\)' 'bar$1' src/*.js
# Literal (non-regex) replace
sd -s '.' '_' filename
Sane Regex, Sane Escaping
sd uses the same modern regex engine as ripgrep, so capture groups are $1, special characters behave predictably, and you don't relearn escaping rules per platform. A literal-string mode handles the cases where you just want to swap exact text without regex at all.
Rough Edges and Limitations
- Not a full sed. sed's stream-editing scripts (line addressing, hold space) are beyond sd's scope by design.
- Another binary. sed is preinstalled; sd is something you add.
- Different syntax. Your sed muscle memory won't transfer - but that's rather the point.
For the common find-and-replace, sd is what sed should feel like: obvious, predictable, and safe to use across files.
Internal link suggestion: link "the same modern regex engine as ripgrep" to the ripgrep post, its search-side sibling.