Instead of sed: sd
Use sd for find and replace at the prompt. It takes the pattern and replacement as two plain arguments, uses the regex syntax you know from JavaScript and Python, and edits files in place without platform-specific flags. Keep sed for anything beyond substitution.
Both are for finding and replacing text in files or a stream.
Why sd is better
- The syntax is simpler. You write sd before after instead of sed s/before/after/g, with no delimiters to escape.
- A string-literal mode (-F) replaces text without any regex escaping.
- In-place editing is the default when you name a file, avoiding sed's -i differences between GNU and BSD.
- It is faster on large inputs. sd's own benchmark shows a regex replacement on a 55M JSON file in 0.942 s against 11.315 s for sed, about 11.93 times faster.
When to keep sed
Keep sed in scripts that must run anywhere, and for anything beyond find and replace: deleting or printing line ranges, multi-command scripts, holding and appending lines. sd does one job.
Switching
Install sd and use it for interactive substitutions. Capture groups are $1 rather than \1. Patterns that span lines need -A (across mode). Existing sed scripts keep working; there is no need to convert them.
Watch out
sd edits files in place by default, so test the pattern on stdin first. It is a small project with few maintainers. It covers only substitution, so you still need sed or awk for other edits.
More newer, better command-line tools
Sources
- sd README and benchmarks
- sed (Wikipedia)
- Modern Unix: alternatives to common Unix commands
- A list of new(ish) command line tools (Julia Evans)
Judged on 2026-11-06. See every command-line tools, or all 66 replacements.