sad
Batch file search-and-replace tool that shows a diff preview before writing changes; optional fzf selection of hunks and delta/diff-so-fancy colorizing.
sad (Space Age seD) is a batch file edit tool. It reads a list of file paths from stdin, applies a regex search and replace across those files, and shows a diff of the proposed changes before anything is written. This addresses the main risk of sed: a mistyped pattern edits files with no chance to review it first.
Usage is find "$FIND_ARGS" | sad '<pattern>' '<replacement>'. If fzf is installed, sad uses it for selection, so you can pick which changes to apply, and files can be multi-selected with Shift+Tab. Hunk size is set with --unified=<n>, as in GNU diff. Without fzf, sad prints the diff to stdout, which can be piped to any git-compatible colorizer such as delta or diff-so-fancy, or passed via --pager or GIT_PAGER. With delta, --pager 'delta -s' gives a side-by-side view.
Other flags include -k/--commit to write all changes without a preview, -0/--read0 for NUL-delimited input, -e/--exact for string-literal matching, and -f/--flags for regex flags. The flags cover case-insensitive (i), multiline (m), dot-matches-newline (s), swapped lazy/greedy (u), and extended whitespace and comments (x). By default sad uses smartcase and multiline matching. Exit codes are 0 for success, 1 for failure, and 130 for interruption; with fzf it always exits 130.
It suits developers who do project-wide refactors or renames from the shell and want to review or selectively accept edits. For plain stdin-to-stdout replacement, the README points to sd or ripgrep with --replace.
Installation
# via Homebrew
brew install sad
# via Pacman
pacman -Syu sad
# via Cargo
cargo install --locked --all-features \
--git https://github.com/ms-jpq/sad --branch senpai


Alternatives & related tools
television
Fuzzy finder for the terminal that searches files, text, git repositories, and custom data sources in real-time
skim
Fuzzy finder written in Rust with interactive search capabilities and shell integration
rga
Line-oriented search tool that extends ripgrep to search inside PDFs, archives, documents, and multimedia files
ast-grep
CLI for structural code search, lint, and rewriting that matches tree-sitter AST nodes using patterns written as ordinary code. Written in Rust.
fd
Fast filesystem search tool that replaces find with regex patterns and smart defaults
add a badge to your README
Maintain sad? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/sad?utm_source=badge)<a href="https://www.trmn.sh/tools/sad?utm_source=badge"><img src="https://www.trmn.sh/badge/sad.svg" alt="Featured on trmn" height="20"></a>