[svlug] extended grep reg exp

David Hummel ddhummel at pacbell.net
Tue Aug 12 13:46:29 PDT 2003


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




More information about the svlug mailing list