> On Jan 11, 2005, at 7:37 AM, David A. Sinck wrote:
> > \_ SMTP quoth David Koopman on 1/11/2005 07:20 as having spake thusly:
> > \_
> > \_ Anybody have a quick easy way to do recursive find and replace?
> > \_
> > \_ Here is my complicated stab at it, but I must say this was a pain to
> > \_ write. I think there must be a utility for doing this to make this
> > \_ much much much easier?
> >
> > find $TOPDIR -type f -exec perl -pi.bak -e
> > 's/&10\.10\.0\.52&i/10.0.0.68/g' {} \;
> >
> > Provides a nice backup in case one of us botches the RE.
>
> That's roughly what I use, too.. except that I've taken to using xargs
> instead of --exec. When using --exec, an instance of perl is
> instantiated for every file found. Not too big a deal if there aren't
> very many files, but it can be a bear if there are.
>
> find $TOPDIR -type f -print0 | xargs -0 perl -pi.bak -e
> 's,&10\.10\.0\.52&i,10.0.0.68,g'
Very cool, thank you so much, this will save me tons of headache in the
future! You guys are awesome for answering, this question has come up
for me over and over again and I've never had a good answer.
I noticed that all files change, regardless of whether they have a match
or not. If this matters:
grep -lri 'blah20' * | xargs perl -pi.bak -e 's/blah20/blah22/gi'
will only change files that have 'blah20' in it.
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss