From a30f616f9f12bc6ff4a9bcdfd486a12cc6f6df39 Mon Sep 17 00:00:00 2001 From: Jesse Claven Date: Fri, 8 Mar 2019 18:17:28 +0000 Subject: [PATCH] sd: add page (#2810) --- pages/common/sd.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pages/common/sd.md diff --git a/pages/common/sd.md b/pages/common/sd.md new file mode 100644 index 000000000..fa9f3f9a5 --- /dev/null +++ b/pages/common/sd.md @@ -0,0 +1,19 @@ +# sd + +> `sd` is an intuitive find & replace CLI. + +- Trim some whitespace using regex: + +`{{echo 'lorem ipsum 23 '}} | sd '\s+$' ''` + +- Replace words using capture groups: + +`{{echo 'cargo +nightly watch'}} | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'` + +- Find and replace in a file: + +`sd -i {{'window.fetch'}} {{'fetch'}} {{http.js}}` + +- Find and replace across a project: + +`sd -i {{'from "react"'}} {{'from "preact"'}} $(find . -type f)`