Find and replace within multiple files

I can’t remember how many times I needed this line recently. I also could never remember it (hm… do you see a pattern here?). So here it is for future reference:

find . -name "*.php" -print | xargs sed -i '.backup' 's/foo/bar/g'

It’s pretty much self explanatory. If I could only make it stick in my brain.

Leave a Reply

Your email address will not be published. Required fields are marked *