perl -i.backup -pe 's/foo/bar/g' filename