How can I replace all instances of ABC
with XYZ
in the current directory and all subdirectories?
In this popular question the top answers note that it's unwise to run commands like
find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
in a folder containing .git
directory, because the history can become corrupted.
How therefore can I do a replace in a folder that does have a .git
directory in it? How's this?:
find /home/www/ -type f -not -path .git/ -exec \
sed -i 's/ABC/XYZ/g' {} +