0
Successful program execution.
sd [{-p | --preview}]
[{-F | --fixed-strings}]
[{-n | --max-replacements}]
[{-f | --flags}]
[{-A | --across}]
[{-h | --help}]
[{-V | --version}]
<FIND>
<REPLACE_WITH>
[FILES]
-p, --preview
Display changes in a human reviewable format (the specifics of the format are likely to change in the future)
-F, --fixed-strings
Treat FIND and REPLACE_WITH args as literal strings
-n, --max-replacements=LIMIT [default: 0]Limit the number of replacements that can occur per file. 0 indicates unlimited replacements
-f, --flags=FLAGS
Regex flags. May be combined (like `-f mc`).
c - case-sensitive
e - disable multi-line matching
i - case-insensitive
m - multi-line matching
s - make `.` match newlines
w - match full words only
-A, --across
Process each input as a whole rather than line by line. This allows patterns to match across line boundaries but uses more memory and prevents streaming
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
The regexp or string (if using `-F`) to search for
What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc
The path to file(s). This is optional - sd can also read from STDIN.
Note: sd modifies files in-place by default. See documentation for examples.
0
Successful program execution.
1
Unsuccessful program execution.
101
The program panicked.
$ echo 'lots((([]))) of special chars' | sd -F '((([])))' ''
lots of special chars
$ echo 'lorem ipsum 23 ' | sd '\s+$' ''
lorem ipsum 23
$ echo 'cargo +nightly watch' | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'
cmd: cargo, channel: nightly, subcmd: watch
$ sd 'window.fetch' 'fetch' http.js
$ sd 'window.fetch' 'fetch' < http.js
3 releases since Debian 12 (Bookworm); the text changed 2 times.
--across since Arch Linux 2026-11-01;
--fixed-strings since Debian 13 (Trixie);
--flags since Debian 13 (Trixie);
--help since Debian 13 (Trixie);
--preview since Debian 13 (Trixie);
--version since Debian 13 (Trixie);
-A since Arch Linux 2026-11-01;
-F since Debian 13 (Trixie);
-V since Debian 13 (Trixie);
-f since Debian 13 (Trixie);
-h since Debian 13 (Trixie);
-p since Debian 13 (Trixie).