Search and Replace in all files within a folder recursively on Linux/Unix

In order to search recursively through directories, looking in all the files for a particular string, then to replace that string with something else (on linux/Unix), these commands should work (Where string1 is the original string and string2 is the replace-string): find ./ -type f -exec sed -i ‘s/string1/string2/’ {} \; It would have been better to use xargs instead of -exec. Using xargs, you will fork fewer times. For large numbers of files, that means you will be done faster. In other words: find ./ -type f | xargs sed -i 's/string1/string2/' Instead of editing all files...

read more