bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bugs in gawk metacharacters


From: Aharon Robbins
Subject: Re: bugs in gawk metacharacters
Date: Tue, 28 Sep 2004 14:17:03 +0200

Greetings. Re this:

> From: "Daniel Gryte" <address@hidden>
> To: <address@hidden>
> Subject: bugs in gawk metacharacters
> Date: Mon, 27 Sep 2004 18:00:26 -0400
>
> I am using RedHat 9.0, GNU bash ver2.05.8 and GNU awk 3.1.0
>
> Suppose the file lab3.data has the following lines:
>
>
> Mike Harrington:(510)548-1278:250:100:175
> Guy Quigley:(916)343-6410:250:100:175
> Chet Main:(510)548-5258:50:95:135
> Elizabeth Stachelin:(916)440-1763:175:75:300
>
>
> The bugs concern the metacharacter syntax for character replication,
> specifically the following:
>
> r{m}        should pick up the character r repeated exactly m times
>
> r{m,}       should pick up the character r repeated at least m times
>
> r{m,n}      should pick up the character r repeated between m and n times
>             inclusive
>
> None of these these items work.
>
> For example, to extract the lines whose first names have EXACTLY 4
> characters the following should work:
>
> awk '/^[A-Z][a-z]{3}/{print $1}' lab3.data
>
> or 
>
> awk '/^[A-Za-z]{4}/{print $1}' lab3.data
>
> Note that + works fine and .  but that all of the character-replications
> with curly braces {} fail.
>
> Sincerely,
>
> Daniel Gryte
> John Abbott College Computer Science Dept.
> Ste Anne de Bellevue, Quebec

Use either gawk --posix or gawk --re-interval to enable interval expressions.
This is documented in the gawk manual.

Have a nice day.

Arnold




reply via email to

[Prev in Thread] Current Thread [Next in Thread]