# sd

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

Stars: 7.4k · Language: Rust · License: MIT · Categories: Dev Tools

- Repository: https://github.com/chmln/sd
- Page: https://www.trmn.sh/tools/sd

## Install

- Cargo: `cargo install sd`

## Overview

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

```bash
# via Cargo
cargo install sd
```

## Alternatives

- [watchexec](https://www.trmn.sh/tools/watchexec.md): File watcher that runs commands when files change, with .gitignore support and cross-platform filesystem monitoring (Rust, 7.3k stars)
- [zizmor](https://www.trmn.sh/tools/zizmor.md): Static analysis tool that finds and fixes security issues in CI/CD configurations, including GitHub Actions workflows, Dependabot, and pre-commit. (Rust, 6.9k stars)
- [tailspin](https://www.trmn.sh/tools/tailspin.md): 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. (Rust, 8.0k stars)
- [tealdeer](https://www.trmn.sh/tools/tealdeer.md): Fast Rust implementation of tldr providing simplified, example-based manual pages for command-line tools (Rust, 6.6k stars)
- [pastel](https://www.trmn.sh/tools/pastel.md): Command-line tool to generate, analyze, convert and manipulate colors across multiple formats and color spaces (Rust, 6.5k stars)

---

Canonical: https://www.trmn.sh/tools/sd
