Browse Source

sd: add page (#2810)

Jesse Claven 6 năm trước cách đây
mục cha
commit
a30f616f9f
1 tập tin đã thay đổi với 19 bổ sung0 xóa
  1. 19 0
      pages/common/sd.md

+ 19 - 0
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)`