NOTE: remember to exclude the .git folder…
Search and replace XXX with YYY in all files:
perl -e "s/XXX/YYY/g;" -pi $(find . -type f)
Troubleshooting
If you get this error:
zsh: argument list too long: perl
Your argument list is clearly too long. Try this instead, or use xargs:
find . \
-type f \
-exec perl -i -pe's/XXX/YYY/g' {} +
Search and Replace with Sed
Using sed is more complicated, but this should at least work on Linux:
# Find, backup and replace
find . -name "*.rb" -print | xargs sed -i.bak 's/XXX/YYY/g'
# Delete backup files
find . -name '*.bak' -type f -delete
Reference.
Also see:
https://snippets.aktagon.com/snippets/861-search-and-replace-file-contents-and-file-names