Find and replace string in files recursively

Last modified: 
Monday, 6. April 2020 - 6:46

This is the best option I have found so far: find . -type f -exec sed -i 's/foo/bar/g' {} +
foo is replaced with bar.

Source: https://linuxize.com/post/how-to-use-sed-to-find-and-replace-string-in-f...

Also quite handy to be able to search and replace filenames.

find . -type f -name 'foo*' | while read FILE ; do
    newfile="$(echo ${FILE} |sed -e 's/foo/bar/')" ;
    mv "${FILE}" "${newfile}" ;
done 

Source: https://unix.stackexchange.com/questions/175135/how-to-rename-multiple-f...