Skip to content

Instantly share code, notes, and snippets.

@jmstfv
Last active November 5, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmstfv/2dbe896eb2554c59621832a4aa043f12 to your computer and use it in GitHub Desktop.
Save jmstfv/2dbe896eb2554c59621832a4aa043f12 to your computer and use it in GitHub Desktop.
Replace all occurrences of a string in any file on MacOS
# Replace all occurrences of a string in any file on MacOS
# Substitute "html" with a target file extension
# using find (built-in)
find . -name '*.html' -print0 | xargs -0 sed -i "" "s/replaceme/withthis/g"
# using fd (https://github.com/sharkdp/fd)
fd -e html --print0 | xargs -0 sed -i "" "s/replaceme/withthis/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment