sd Simple find and replace
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
sd <find> <replace> <file>
sd -p <find> <replace> <file>
<cmd> | sd <find> <replace>
sd -F <text> <replace>
sd '(\w+)@(\w+)' '$2 at $1'
sd -A '\n' ' '
sd -n 1 <find> <replace>
sd -f i <find> <replace>
Concepts
- Input files or stdin
- Regex find Rust syntax
- Replacement $$ = literal $
- Output file or stdout
Basics
sd <find> <replace> <file>...
<cmd> | sd <find> <replace>
sd <find> <replace> < <file>
sd -p <find> <replace> <file>
sd -F <text> <replace>
sd -n <count> <find> <replace>
sd -A <find> <replace>
sd -- <find> <replace>
sd --versionsd --helpPatterns
sd '\s+$' ''
sd '^\s+' ''
sd '\d+' '<n>'
sd '\bfoo\b' bar
sd '^#.*\n' '' -A
sd 'a|b' c
sd '(?i)error' warn
sd '\.' ','
sd '^$' '<text>'
sd '(?s)<a>.*</a>' '' -A
Replacement
sd '(\w+) (\w+)' '$2 $1'
sd '(?P<k>\w+)=(?P<v>\w+)'
'$v=$k'
sd '(\w+)' '${1}_x'
sd foo '$$bar'
sd '(a)(b)' '$0'
sd -F '$' '<text>'
Regex flags
sd -f i <find> <replace>
sd -f c <find> <replace>
sd -f w <find> <replace>
sd -f m <find> <replace>
sd -f e <find> <replace>
sd -f s <find> <replace>
sd -f im <find> <replace>
Files and pipelines
sd <find> <replace> <f1> <f2>
fd -t f -x sd <find> <replace>
rg -l <find> | xargs sd <find>
<replace>
git ls-files | xargs sd <find> <replace>
echo <text> | sd <find> <replace>
From sed
| sed | sd |
|---|---|
sed 's/a/b/g' |
sd a b |
sed -i 's/a/b/g' f |
sd a b f |
sed -E 's/(a)(b)/\2\1/' |
sd '(a)(b)' '$2$1' |
sed 's/a/b/' |
sd -n 1 a b |
sed 's/a/b/I' |
sd -f i a b |
sed 'N;s/\n/,/' |
sd -A '\n' ',' |
sed -n '/x/p' |
not supported: use rg or grep |
Recipes
git status --short # clean tree firstfd -t f -e js -x sd -p 'oldName' 'newName'fd -t f -e js -x sd 'oldName' 'newName'git diff
echo '2026-10-21' | sd '(\d+)-(\d+)-(\d+)' '$3.$2.$1'# 21.10.2026
printf 'a\nb\nc\n' | sd -A '\n' ','# a,b,c,
sd -F 'foo((([])))' 'bar' notes.txt



