Replace string in all files in a folder and subfolders.

i need to change string in all files in current folder and all subfolders. i wrote the following script. It works good except it dont delete temp file from subfolders.

for z in `find . -type f -name ".html" -o -name ".htm"`; do
sed -e 's@abc@xyz@g' $z>temp;
mv temp $z;
done

any idea? or any other better solution?

Thanks it worked

need some more guidence

i also need to make changes according to file types like this

for z in `find . -type f -name "*.PHP"`; do
sed -e 's@123@456@g' $z>temp;
mv temp $z && rm temp;
done

for z in `find . -type f -name "*.html" -o -name "*.htm"`; do
sed -e 's@abc@xyz@g' $z>temp;
mv temp $z && rm temp;
done

any other better way to do this instead of using 2 loops?