$cargo install sd
AI Analysis
sd is a focused find-and-replace CLI for regex or literal text substitutions in stdin streams and files. It is a local text-transformation primitive for refactors, content cleanup, and scripted rewrites.
What It Enables
- Rewrite matching text in stdin pipelines or files with regex captures or fixed-string replacements.
- Preview replacements before writing, or apply them in place across many files when paired with tools like
fdorxargs. - Handle line-oriented streaming by default, or switch to whole-input mode for multiline patterns and newline replacements.
Agent Fit
- stdin and file inputs, stable flags, and in-place editing make it easy to drop into shell loops for local refactors.
- Text output and exit behavior are predictable, but there is no JSON mode and
--previewis explicitly a human-readable format that may change. - Best for local code, config, or content rewrites inside larger workflows rather than service or API operations.
Caveats
- Files are modified in place by default unless you use
--preview, so automated runs should stage changes or rely on version control. - Multiline work needs
--across, which reads whole inputs, uses more memory, and disables streaming.