Files
tldr/pages.zh/common/sd.md

20 lines
637 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# sd
> 直观的查找和替换。
> 更多信息:<https://github.com/chmln/sd>。
- 使用正则表达式修剪一些空白(输出流:`stdout`
`{{echo 'lorem ipsum 23 '}} | sd '\s+$' ''`
- 使用捕获组替换单词(输出流:`stdout`
`{{echo 'cargo +nightly watch'}} | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'`
- 在特定文件中查找和替换(输出流:`stdout`
`sd -p {{'window.fetch'}} {{'fetch'}} {{path/to/file.js}}`
- 在当前项目的所有文件中查找和替换(输出流:`stdout`
`sd {{'from "react"'}} {{'from "preact"'}} "$(find . -type f)"`