[OT] - subthread - perl vs sed Re: [olug] Text search and Replace
Brian Roberson
roberson at olug.org
Tue Nov 25 17:20:50 UTC 2003
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
>
More information about the OLUG
mailing list