I ran into an interesting problem at work today. We have 50 copies of the same PHP file (we have a server that contains historical versions of our site so people can see what the site looked like at a point in time) and I needed to fix a single line in all of them. This is an easy problem to fix with sed but we had two files with the same name in two different directories. To fix this I had to do a slightly more complex search for the files before we replaced them:

find . -name FileName.php | grep folderName | xargs sed -i 's/originalText/newText/g'

As always with posts that could mess up data, I take no responsibility for any lost data. I suggest you run this on a single file first to make sure it doesn't have any unattended consequences and backup anything that's going to be changed.