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.
# via Cargo
cargo install sd