sd(1) General Commands Manual sd(1)


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
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.

Successful program execution.
Unsuccessful program execution.
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