The following script (Linux bash) does a find and replace on a multiple files including the content of those files. Here is the script.
#!/bin/sh
if [ $# -lt 2 ] ; then
echo -e "Wrong number of parameters"
echo -e "Usage:"
echo -e " $0 findstring replacestring filepattern\n."
exit 1
fi
fstring="$1"
rstring="$2"
if [ "$3" = "" ]
then
somefiles="*"
else
somefiles="$3"
fi
echo "find: |${fstring}|"
echo "replace: |${rstring}|"
find . -depth -name "${somefiles}" \! -name ".svn*" -type f -exec sed -i "s/${fstring}/${rstring}/g" {} \;
for FILE in `find . -depth -name "${somefiles}" \! -name ".svn*"`
do
NEW=`echo ${FILE} | sed -e "s/${fstring}/${rstring}/"`
if [ "${NEW}" = "${FILE}" ]
then
:
else
echo $0: mv ${FILE} ${NEW}
mv ${FILE} ${NEW}
fi
done