explaingit

chmln/sd

7,114RustAudience · developerComplexity · 1/5Setup · easy

TLDR

sd is a fast Rust command-line tool for finding and replacing text in files, with a cleaner syntax than sed, modern regex support, and 2-12x better performance on regex-heavy tasks.

Mindmap

mindmap
  root((sd))
    What it does
      Find and replace
      Modern regex
      Multiline mode
    Tech Stack
      Rust
      CLI tool
    Use Cases
      Edit source files
      Transform piped text
    Features
      Plain string mode
      Preview changes
    Audience
      Developers
      Shell users
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace all occurrences of an old function name across multiple source files in one command.

USE CASE 2

Transform text piped from another command, such as replacing commas with newlines in CSV output.

USE CASE 3

Use plain-string mode to safely replace text containing dots, brackets, or other regex special characters without escaping them.

USE CASE 4

Preview what changes sd would make to a file before committing them.

Tech stack

Rust

Getting it running

Difficulty · easy Time to first run · 5min

Install via cargo or a system package manager, no configuration needed.

In plain English

sd is a command-line tool for finding and replacing text in files or piped input. It is written in Rust and designed as a simpler alternative to the traditional sed tool that ships on Unix-like systems. The basic usage is just sd followed by the text to find and the text to replace it with, and optionally one or more file names to modify in place. The main differences from sed are in readability and regex syntax. sed uses a compressed format where the find pattern, replacement, and flags are all packed into one argument separated by slashes, which makes expressions with slashes in them messy to write. sd splits the find and replacement into two separate arguments, so there is nothing to escape. The regex syntax also matches what you would find in JavaScript or Python rather than the older POSIX-style syntax sed uses. By default, sd processes text one line at a time, which keeps memory usage low and works well for most replacements. An across mode is available with the -A flag when you need a pattern to span multiple lines, for example to replace newlines with commas. The README includes benchmark results showing sd runs roughly 2 to 12 times faster than sed depending on the task, with the larger speedups on regex-heavy workloads. A plain string mode turns off regex interpretation entirely, which is useful when the text you are searching for contains characters that would normally have special meaning in a regex pattern. A preview flag lets you see what changes would be made before committing them to a file. Installation is available through the Rust package manager cargo or through various system package managers. The README lists packaging status across distributions.

Copy-paste prompts

Prompt 1
Using sd, replace every instance of 'foo' with 'bar' in all .js files in the current directory in place.
Prompt 2
Show me how to use sd's multiline mode with the -A flag to replace a pattern that spans multiple lines in a file.
Prompt 3
How do I use sd in plain-string mode to replace a string that contains dots and parentheses without treating them as regex?
Prompt 4
Walk me through using sd to rename a variable across an entire Python project, and preview the changes before applying them.
Prompt 5
What is the difference between sd and sed when handling replacements that contain forward slashes, and how does sd make it simpler?
Open on GitHub → Explain another repo

← chmln on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.