Replacing string in multiple files

Hi,

I need to replace the string 'abcd' with 'xyz' in a file sample.xml
This sample.xml is also present in the subdirectories of the current directory.

Eg,

If I am in /user/home/

the sample.xml if present in
/user/home/
/user/home/folder1/
/user/home/folder2/
/user/home/folder2/subfolder1/

I tried using
sed "s/abcd/xyz/g" sample.xml > temp; mv temp sample.xml;

But this replaces only the sample.xml in /user/home/ directory.

Please help on this

Please test and try this....

 
for i in `find /user/home/ -type f`
do
sed "s/abcd/xyz/g" $i > temp; mv temp $i;
done

Hi,

I modified little bit and this worked.

for y in `find . -name sample.xml`;
do 
sed 's/abcd/xyz/g' $y > temp; mv temp $y;
done

Thanks for your help

Another variation

find ~ -name "sample.xml" -exec sed -i 's/abcd/xyz/' {} \;

Warning: But be very careful while running all these, as it will recursively edit all the sample.xml file in your home directory.