[svlug] extended grep reg exp

Robert Khachikyan rhxk at earthlink.net
Tue Aug 12 14:14:12 PDT 2003


Indeed it can be done in awk or sed. This file is about 180MB.
If I awk it, it'll load the file to memory serially and read
it line by line...not sure if sed does that...
But it's going to run under a cron every hour in a system where
the CPU & memory are taken by other higher priority processes. If I
crash the system, or make it a bit slower, i'm going to piss off
lots of people...that's why i'm trying to stay away from awk.

& since grep doesn't open the file, it won't use as much resources
as awk (i think sed too..but not sure)

The script is a perl script that calculates some formulas
and results in 3918404. & I know i want every record until
the 3928405. But there are duplicates in the middle where
for each number there are different values of bla bla.


As Always,
...Robert

> -----Original Message-----
> From: svlug-bounces+rhxk=earthlink.net at lists.svlug.org
> [mailto:svlug-bounces+rhxk=earthlink.net at lists.svlug.org]On Behalf Of
> David Hummel
> Sent: Tuesday, August 12, 2003 1:46 PM
> To: svlug at lists.svlug.org
> Subject: Re: [svlug] extended grep reg exp
> 
> 
> On Tue, Aug 12, 2003 at 01:21:03PM -0700, Robert Khachikyan wrote:
> > I have a big file that has
> > 
> > 3918403 bla bla bla
> > 3918404 bla bla bla
> > ...
> > 3945785 bla bla bla
> > 3945786 bla bla bla
> > 
> > you get the idea. I want to grep a portion of it out.
> > Let's say from 3918403 -> 3928404 (10001 lines).
> > 
> > i thought 'egrep -E 39[18403-28404] file' would do, but
> > it comes back with no match...
> 
> [18403-28404] is a nonsensical character set.  [] is designed to take
> ranges of individual characters lexicographically, such as [A-Z0-9], not
> ranges of integers.
> 
> If you know that you need 10000 lines after 3918403, you can do it like
> so:
> 
>   grep -A 10000 3918403 file
> 
> or here's another solution using sed:
> 
>   sed -n '/3918403/,/3928404/p' file
> 
> David Hummel
> Genomics & Gene Discovery
> WRRC/ARS/USDA
> 
> _______________________________________________
> svlug mailing list
> svlug at lists.svlug.org
> http://lists.svlug.org/lists/listinfo/svlug




More information about the svlug mailing list