sd
Find and replace CLI tool with regex support, string-literal mode, and faster performance than sed
sd is a command-line find and replace tool that serves as an alternative to sed with simplified syntax and enhanced performance. It supports both regex patterns using JavaScript/Python-compatible syntax and string-literal mode for exact text matching without escaping special characters. The tool processes files in-place by default, with options for previewing changes before applying them.
The tool offers two processing modes: line-by-line (default) for low memory usage and streaming output, and across mode (-A flag) for patterns that span multiple lines. It includes support for both indexed and named capture groups, with straightforward replacement syntax using $1, $2 or $varname notation. Performance benchmarks show sd running 2-12 times faster than sed on various workloads while maintaining lower memory usage in line-by-line mode.
sd integrates well with other command-line tools through Unix pipes and can be combined with tools like fd for project-wide find and replace operations. It handles edge cases like arguments starting with dashes through standard -- convention and provides escape mechanisms for special characters in replacement patterns.
Installation
# via Cargo
cargo install sd
Alternatives & related tools
watchexec
File watcher that runs commands when files change, with .gitignore support and cross-platform filesystem monitoring
zizmor
Static analysis tool that finds and fixes security issues in CI/CD configurations, including GitHub Actions workflows, Dependabot, and pre-commit.
tailspin
Log file highlighter (binary: tspin) that colors dates, numbers, IPs, UUIDs, URLs and more in any log format, with no config, and pages output through less.
tealdeer
Fast Rust implementation of tldr providing simplified, example-based manual pages for command-line tools
pastel
Command-line tool to generate, analyze, convert and manipulate colors across multiple formats and color spaces
add a badge to your README
Maintain sd? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/sd?utm_source=badge)<a href="https://www.trmn.sh/tools/sd?utm_source=badge"><img src="https://www.trmn.sh/badge/sd.svg" alt="Featured on trmn" height="20"></a>