I came across a neat method of replacing a string in loads ‘o’ files today.
Basically pipe the output of grep for your search string into sed doing a regex replace on the string.
grep -lre 'SEARCH_STRING' . | xargs -d'\n' sed -i "s/SEARCH_STRING/REPLACE_STRING/g"
…which is basically the same as doing
find . -type f -exec grep -q ‘SEARCH_STRING’ -exec sed -i ’s/SEARCH_STRING/REPLACE_STRING/g’ {} \;
…which in turn is the same as
find . -type f -exec sed -i ’s/SEARCH_STRING/REPLACE_STRING/g’ {} +
Nice, I actually like the last one you said - shorter