sd

Find and replace CLI tool with regex support, string-literal mode, and faster performance than sed

install· Cargo

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

add a badge to your README

Maintain sd? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/sd.svg)](https://www.trmn.sh/tools/sd?utm_source=badge)
HTML
<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>