OT: looking for text file find and replace utility
david nicol
whatever at davidnicol.com
Thu Sep 4 08:07:06 CDT 2003
Here's one approach
Make a simple perl program that expands your 400 find/replace terms
into 400 lines of the form
s/bcatb/dog/g;
and call that script subs.pl
Then invoke perl with the -p switch which causes the whole script
to get wrapped in a wrapper which processes input and writes output
also use the -i switch which causes the named data files to get replaced
with the processing output
Make a backup of your scripts in case something goes wrong, then
run
perl -pi subs.pl script1 script2 script3 script4 sctip5 script6
And then all the substitutions will be performed in all the scripts.
On Fri, 2003-08-29 at 14:53, KRFinch at dstsystems.com wrote:
>
>
> Hello all!
>
> I've run into a bit of a problem and I was hoping someone out there in
> TV-Land might know the right tool for the job.
>
> I have a group of 6 scripts that I need to do multiple find and replace
> operations on. Basically the find and replace operations are all simple
> 'change all instances of "cat" to "dog"' type operations, but I have
> upwards of 400 of these searches that I need to be performed against each
> of these 6 scripts. The thought of doing that manually gives me the
> willies, and it would take a lot of time. I'd really like something I
> could just feed lists of variables into and let it go to town, even if it
> only did it for one file at a time.
>
> I know that I could probably grep this all up pretty nicely (if I knew
> how), but I'm kinda stuck with Wintel tools. Anyone out there come across
> any Wintel tools to batch lots of text file find and replace operations?
>
> Thanks!
>
> Kevin Finch
> Network Administrator
> DST Systems, Inc.
> 816/435-6039
> krfinch at dstsystems.com
>
>
>
>
--
David Nicol / If at first you don't succeed, use a bigger hammer.
http://gallaghersmash.com
More information about the Kclug
mailing list