Skip to content

sd

sd is an intuitive find & replace command line tool.

🛠 Installation

sudo apt install sd
sudo apt install sd
brew install sd

📝 Usage

1. Replace a string

echo "hello world" | sd "world" "there"
# Output: hello there

2. Replace all occurrences of a string

echo "hello world world" | sd -s "world" "there"
# Output: hello there there

3. Replace using regular expressions

echo "foo 123 bar" | sd "\d+" "NUM"
# Output: foo NUM bar

4. Replace in a file (in-place)

sd "old_string" "new_string" file.txt

🔗 References