[svlug] extended grep reg exp

Piotr T Zbiegiel peter at usestrict.org
Tue Aug 12 13:40:19 PDT 2003


Not a regex, but a perl one-liner:

perl -ne '/^(39[12]\d\d\d\d)/; print if $1 >= 3918403 && $1 <= 3928404'
<file>

HTH
Peter

On Tue, 2003-08-12 at 13:21, Robert Khachikyan wrote:
> I've read the doc for grep extensively and google searched
> it and still couldn't find what i was looking for...on top
> of that, i left my reg exp book @ home....so here it is.
> 
> I have a big file that has
> 
> 3918400 bla bla bla
> 3918401 bla bla bla
> 3918402 bla bla bla
> 3918403 bla bla bla
> 3918404 bla bla bla
> ...
> 3945785 bla bla bla
> 3945786 bla bla bla
> 3945787 bla bla bla
> ...
> 
> you get the idea. I want to grep a portion of it out.
> Let's say from 3918403 -> 3928404 (10001 lines).
> 
> To my knowledge, grep's regular expression works with
> searching for the last character of the string(*[0-9]).
> This would return only 10 lines...what if I want to
> do a crazy grep like this?
> 
> i thought 'egrep -E 39[18403-28404] file' would do, but
> it comes back with no match...
> 
> can anyone shine a light on this....thanks a mill
> 
> 
> As Always,
> ...Robert
> 
> _______________________________________________
> svlug mailing list
> svlug at lists.svlug.org
> http://lists.svlug.org/lists/listinfo/svlug





More information about the svlug mailing list