I used this:
grep -r "old_string" -l | tr '\n' ' ' | xargs sed -i 's/old_string/new_string/g'
List all files that contain
old_string.Replace newline in result with spaces (so that the list of files can be fed to
sed.Run
sedon those files to replace old string with new.
Update: The above result will fail on filenames that contain whitespaces. Instead, use:
grep --null -lr "old_string" | xargs --null sed -i 's/old_string/new_string/g'
grep --null -lr "old_string" | xargs --null sed -i 's/old_string/new_string/g'