sd(1) General Commands Manual sd(1)

sd

sd [-p|--preview] [-F|--fixed-strings] [-n|--max-replacements] [-f|--flags] [-h|--help] [-V|--version] <FIND> <REPLACE_WITH> [FILES]

Display changes in a human reviewable format (the specifics of the format are likely to change in the future)
Treat FIND and REPLACE_WITH args as literal strings
Limit the number of replacements that can occur per file. 0 indicates unlimited replacements
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

Print help (see a summary with '-h')
Print version
<FIND>
The regexp or string (if using `-F`) to search for
<REPLACE_WITH>
What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc
[FILES]
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 -s '((([])))'
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'
123 dollars and 45 cents
$ sd 'window.fetch' 'fetch' http.js
$ sd 'window.fetch' 'fetch' < http.js
sd 1.0.0