2019-03-08 18:17:28 +00:00
|
|
|
# sd
|
|
|
|
|
2023-07-16 18:23:40 +01:00
|
|
|
> Intuitive find and replace.
|
meshlabserver, nkf, obs, pax, pdfimages, pinky, pssh, s, sd, sendmail, sftp: add link (#6971)
2021-10-17 05:23:56 +01:00
|
|
|
> More information: <https://github.com/chmln/sd>.
|
2019-03-08 18:17:28 +00:00
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
- Trim some whitespace using a regular expression (output stream: `stdout`):
|
2019-03-08 18:17:28 +00:00
|
|
|
|
|
|
|
`{{echo 'lorem ipsum 23 '}} | sd '\s+$' ''`
|
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
- Replace words using capture groups (output stream: `stdout`):
|
2019-03-08 18:17:28 +00:00
|
|
|
|
|
|
|
`{{echo 'cargo +nightly watch'}} | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'`
|
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
- Find and replace in a specific file (output stream: `stdout`):
|
2019-03-08 18:17:28 +00:00
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
`sd -p {{'window.fetch'}} {{'fetch'}} {{path/to/file.js}}`
|
2019-03-08 18:17:28 +00:00
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
- Find and replace in all files in the current project (output stream: `stdout`):
|
2019-03-08 18:17:28 +00:00
|
|
|
|
2022-12-14 12:43:44 +00:00
|
|
|
`sd {{'from "react"'}} {{'from "preact"'}} "$(find . -type f)"`
|