views:

129

answers:

2

Hello Members.

I have 1000 files in a directory. I'm on a solaris machine

I want to replace the string " /example/test/temp " t0 " /testing/in/progress/ in all the xml files in my directory.

any pointers will be great.

thanks,

novice

A: 

Use sed(1).

In general it is safer to use an xslt processor to massage XML files, but in this particular example, the chances of some "funky" XML representation causing problems is pretty remote ...

Stephen C
A: 

How about (all on one line):

find . \( -type d ! -name . -prune \) -o \( -type f -name "*.xml" -print \) |
    xargs perl -i.old -p -e 's-/example/test/temp-/testing/in/progress/-g'
toolkit
thanks for the solution. But the control seems to be going into some sort of infinite loop, creating files like filename.oldfilename.old.old, filename.old.old.old etc .. How do I modify it such that no back up (.old) files are genearated ? many thx.
novice
Why don't you just use `-maxdepth`? `find . -maxdepth 1 -type f -name "*.xml" -print` - Also, you should use `-print0` with `find` and `-0` with xargs.
Dennis Williamson
Dennis - not all finds are equal. Some don't have maxdepth :-(novice - to get rid of the .old files, change perl -i.old to perl -i (thought that means if you get your regexp wrong, you don't have a backup to revert to)
toolkit
Thanks toolkit! I was a little puzzled on how to get rid of the old files! thanks again!
novice