sd

github.com ↗

Replace text in files or streams with a compact, readable command-line syntax.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Not confirmed
Sign-up required
Not required AI reading, not confirmed

Ask SI about sd

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the sd homepage

What it does

sd is a focused find-and-replace utility for the terminal. It accepts a search pattern and replacement as separate arguments, uses regular expressions by default, and offers a fixed-string mode for text that should not be interpreted as a pattern. It can read from standard input or modify named files, making it useful for a small transformation in a script or a targeted edit across project files.

Try a literal replacement on a stream

A harmless first example is to pass a short string through standard input:

printf 'debug mode\n' | sd -F debug release

The -F option treats debug as literal text, so brackets, dots and other regular-expression characters do not need escaping. Without that flag, the search expression is a regex, and capture groups can be referenced in the replacement. This split-argument syntax is handy when changing a value in a generated text file or renaming a token in a small project configuration.

For a named file, sd before after file.txt edits the file in place. Try the operation on a copy or a version-controlled worktree before applying it broadly; a mistaken pattern can change many matches. The project is intentionally narrower than a general stream editor such as sed: it concentrates on find and replace rather than providing a broad set of text-processing commands.

The repository documents Cargo installation and packages from multiple maintainers. It does not require a hosted service or account for the local CLI, and its source is MIT licensed. No benchmark claims are needed to choose it: the main reason to use sd is its direct search-and-replacement interface.

Strengths

  • Keeps the search expression and replacement in separate arguments, avoiding delimiter-heavy substitution syntax.
  • Offers a fixed-string option as well as regex captures and stdin input.

Watch out for

  • Named files are modified in place, so broad replacements should be previewed on a copy or reviewed in version control.
  • Its deliberately narrow purpose does not replace a general-purpose stream editor for other text-processing tasks.

Best for

  • Making a focused text replacement in project files or generated output
  • Using familiar regular expressions or literal strings in a shell pipeline

Sources