sd(1)
π sd(1) β General Commands Manual, but make it group chat π
okay so this is sd(1) from the General Commands Manual, and it's giving find-and-replace main character energy. Bestie, if you've ever wanted to search for a regexp or a literal string and swap it out with something else β while looking cute β this is your moment. π
β¨
πΈ NAME πΈ
okay so the name is literally sd β that's the whole NAME section, bestie. Short, iconic, no notes. π
π¦ SYNOPSIS π¦
sd [-p|--preview] [-F|--fixed-strings] [-n|--max-replacements]
[-f|--flags] [-A|--across] [-h|--help] [-V|--version] <FIND>
<REPLACE_WITH> [FILES]
π DESCRIPTION π
okay so this DESCRIPTION section is literally empty β no prose, no deets, just a heading doing abs. π The real tea is in OPTIONS, so scroll with me. π«Ά
π OPTIONS π
-p,--previewβ displays changes in a human reviewable format. Heads up: the specifics of that format are likely to change in the future. π-F,--fixed-stringsβ treatsFINDandREPLACE_WITHargs as literal strings. No regex shenanigans, just exact-string energy. π-n,--max-replacements=LIMITβ[default: 0]limits the number of replacements that can occur per file.0indicates unlimited replacements, so0is the no-cap setting, fr fr. π₯-f,--flags=FLAGSβ regex flags. May be combined (like-f mc).cβ case-sensitiveeβ disable multi-line matchingiβ case-insensitivemβ multi-line matchingsβ make.match newlineswβ match full words only
-A,--acrossβ processes 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. iconic but not free, bestie. π-h,--helpβ print help (see a summary with-h). yes, that's what it says. iykyk. π-V,--versionβ 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. captured-value slay. β¨[FILES]β the path to file(s). This is optional βsdcan also read from STDIN.
Note: sd modifies files in-place by default. See documentation for examples.
π EXIT STATUS π
0β successful program execution. slay. β1β unsuccessful program execution. not the vibe. π101β the program panicked. literally screaming. π
π EXAMPLES π
String-literal mode
the -F girlies know: literal strings only, no regex chaos.
$ echo 'lots((([]))) of special chars' | sd -F '((([])))' ''
lots of special chars
Regex use. Let's trim some trailing whitespace
look at that trailing whitespace getting evicted. bye bestie. π
$ echo 'lorem ipsum 23 ' | sd '\s+$' ''
lorem ipsum 23
Indexed capture groups
capture groups are eating, no cap.
$ echo 'cargo +nightly watch' | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'
cmd: cargo, channel: nightly, subcmd: watch
Find & replace in file
in-place glow-up for http.js. π
$ sd 'window.fetch' 'fetch' http.js
Find & replace from STDIN an emit to STDOUT
yes, the original says βan emitβ β we don't fix lore. π«Ά
$ sd 'window.fetch' 'fetch' < http.js
okay that's the whole page, bestie β source/version: sd 1.0.0, manual: sd(1). The footer didn't give a date, so no fake timestamp energy here. mwah ππ«Άβ¨
π¦ where this page comes from
- arch rolling: sd 1.1.0-1 Β· MIT
- nixos 26.05: sd 1.1.0
- nixpkgs unstable: sd 1.1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms