[Bash-scripts] Recursive String Replacement

I had a bunch of makefiles that needed editing–finding and replacing occurrences of strings. It would have taken a long time to manually do it. I used the simple bash scirpt below to recursively barrow into all sub-directories, and subsequently find and replace all occurrences of strings in question.


for mfile in `find . -iname "Makefile"`
echo "Now processing..."$mfile
sed -i 's/tomcat6/tomcat7/g' $mfile

Notice that the files I’m looking for have a consistent naming convention–Makefile. However, this could easily be modified. In addition, I’m looping through results returned by find command.