I'll take a swing.

I'd modify the .* expression, which will match any character any number of
times, including zero.  I would be more explicit and say that you want to
match any character other than the delimiter any number of times, followed
by the delimiter, and match the preceding group exactly 2 times.  So .*
becomes [^;]*

egrep -e '^([^;]*;){2}201110' filename.csv




On Tue, Jan 24, 2012 at 12:16 PM, David Roth <uzz...@gmail.com> wrote:

> I haven't tested this, but I believe what you wanted was something
> more like the following:
>
> egrep -e '^(.*;){2}201110' filename.csv
>
> The curly brace operators are used to indicate how many times the
> previous element should be matched.  Putting curly braces around a
> matching pattern is a no-op.  You want to follow your pattern group
> "(.*;)" with the number of matches "{2}".
>
> -David
>
> On Tue, Jan 24, 2012 at 9:05 AM, William Kreuter <bil...@drizzle.com>
> wrote:
> > I want to select every line from a csv file which has the literal
> "201110"
> > in the third field.  Neither of the following do it.
> >
> > egrep -e '^{.*;}{2}201110' filename.csv
> >
> > egrep -E '^{.*;}{2}201110' filename.csv
> >
> > I haven't really figured out the use of curly braces. It seems that
> they're
> > for both grouping (as in the left pair on these lines) and repetition
> (as in
> > the right pair).  My impression right now is that it's one, or both, of
> the
> > curly-brace pairs which is doing something different than I want.
> >
> > I'm by no means wedded to egrep, if sed or awk or something can do it in
> a
> > few keystrokes.
> >
> > Billy
>
>
>
> --
> Omnis Gratiae Solanum Tuberosum Fons Est
>



-- 
Steve McCarthy
    s...@mccrew.com
    mcc...@gmail.com

Reply via email to