Here's the test script I'm running
matt@server:~ $ cat test.sh
#!/bin/bash
mkdir test
cd test
echo "has the string foo" > yes.txt
echo "hasn't the string" > no.txt
ls -l --time-style=full-iso
cat *
perl -e 's/foo/bar/g;' -pi $(find -type f)
ls -l --time-style=full-iso
cat *
matt@server:~ $ ./test.sh
total 8
-rw-r--r-- 1 matt matt 18 2011-01-29 13:52:17.240316663 -0700 no.txt
-rw-r--r-- 1 matt matt 19 2011-01-29 13:52:17.240316663 -0700 yes.txt
hasn't the string
has the string foo
total 8
-rw-r--r-- 1 matt matt 18 2011-01-29 13:52:17.260317727 -0700 no.txt
-rw-r--r-- 1 matt matt 19 2011-01-29 13:52:17.260317727 -0700 yes.txt
hasn't the string
has the string bar
I need to figure out how to tweak this line:
perl -e 's/foo/bar/g;' -pi $(find -type f)
To not write every file it finds but to just write the files that need to be changed.