[OT] - subthread - perl vs sed Re: [olug] Text search and Replace

Eric Pierce eric_olug at yahoo.com
Tue Nov 25 19:10:50 UTC 2003


Sed resource:
http://www-106.ibm.com/developerworks/linux/library/l-sed1.html
Awk resource:
http://www-106.ibm.com/developerworks/linux/library/l-awk1.html

EP
--- Tim - DZ <iceburn at dangerzone.com> wrote:
> I sort of know what sed can do and have actually used code snips (aquired
> from various places - like the one Brian just posted), but haven't sat down
> to actually google / read man pages / etc.
> 
> Does anyone have/know of a 'one sheeter' that kinda gives an intro to sed
> and awk somewhere?  How they kinda work, the idea behind, where to use and
> where not to...
> 
> -t 
> 
> 
> PS sorry about the post that basically repeated Terry's solution, for some
> reason some mail was lagging on delivery...
> 
> 
> -----Original Message-----
> From: olug-bounces at olug.org [mailto:olug-bounces at olug.org] On Behalf Of
> Brian Roberson
> Sent: Tuesday, November 25, 2003 11:21 AM
> To: Omaha Linux User Group
> Subject: [OT] - subthread - perl vs sed Re: [olug] Text search and Replace 
> 
> While I am a huge fan of perl, I must say that it is overkill on things like
> this, say you had directory with 50,000 files... just think about spawning
> perl 50,000 time's vice sed plus the overhead that perl would add if the
> files where 10Mb+ in size. AFAIK - perl would load 10Mb into resident mem
> before even doing the substitution. sed uses the file control function fseek
> when you give it a filename instead of standard out.
> 
> 
> -- just an observation :)
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Terry" <td3201 at yahoo.com>
> To: <jnorton at jggt.com>; "Omaha Linux User Group" <olug at olug.org>
> Sent: Tuesday, November 25, 2003 10:52 AM
> Subject: Re: [olug] Text search and Replace
> 
> 
> > lots of ways to do it, here is a 1-liner for you:
> > perl -i.backup -pe 's/foo/bar/' filename
> >
> > you can write a loop around this easy enough in bash
> > to go through all files in a directory.
> >
> > This replaces all occurrences of foo with bar.  You
> > might need to tack on a g at the end of the regexp but
> > I don't think so.
> >
> > --- Jeff Norton <jnorton at jggt.com> wrote:
> > > I want to search a directory on my computer and
> > > replace certain text
> > > within documents with a new text.
> > >
> > > _______________________________________________
> > > OLUG mailing list
> > > OLUG at olug.org
> > > http://lists.olug.org/mailman/listinfo/olug
> >
> >
> > =====
> > Terry
> >
> > __________________________________
> > Do you Yahoo!?
> > Protect your identity with Yahoo! Mail AddressGuard
> > http://antispam.yahoo.com/whatsnewfree
> > _______________________________________________
> > OLUG mailing list
> > OLUG at olug.org
> > http://lists.olug.org/mailman/listinfo/olug
> >
> 
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
> 
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


More information about the OLUG mailing list