The format is as follows:
grep -rl stringToFind somedir/ | xargs sed -i 's/stringToFind/replacementString/g'
For example: I wanted to replace the string 'SCOpe' with 'SCOPE'. The following is what I used:
grep -rl 'SCOpe' ./ | xargs sed -i 's/SCOpe/SCOPE/g'
This will search for the string 'SCOpe' in all files relative to the current directory and replace 'SCOpe' with 'SCOPE' for each occurrence of the string in each file.
No comments:
Post a Comment