Recursively search and replace text in all files in #MacOS


find files based on file extension
use -print0 to terminate strings with null strings, instead of newline characters
This allows proper interpretation of strings with spaces
plays well with xargs -0
xargs and sed to replace with a regex string
use -0 to look though lists separated by null strings
use -i "" to ignore these null strings


find . -name '*.txt' -print0 | xargs -0 sed -i "" "s/form/forms/g"


While migrating Roam to LogSeq , I had to replace all :: with : , which roam uses as a shortcut page with different formatting, and which is unsupported on LogSeq.
find . -name '*.md' -print0 | xargs -0 sed -i "" "s/::/:/g"
The above command made it super easy