find . -name "*.html" -type f -exec grep -l foo {} \; | perl -pi -e 'BEGIN{ @ARGV = ; chomp @ARGV }; while (<>) { s/foo/bar/g; } continue { print }'