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

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

Re: egrep bug


From: Tom Hageman
Subject: Re: egrep bug
Date: Thu, 5 Nov 2009 01:46:46 +0100

Hi  Jonathan,

In article <address@hidden>, you wrote:
> Hi,
>
> I have grep/egrep version:
> Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There
> is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>
> for snow leopard. When i type the phrase:
>
> cat /usr/share/dict/words | egrep --color '([aeiou][^aeiou]*){8}'
>
> it should return every dictionary entry with 8 vowels. It does this on
> my linux machine and my labmate's linux machine, but not on my mac or
> on any other mac I've tried it on. Thanks,
>
> Jon

Seems to work on Mac OS X (Tiger) 10.4.11, except for the --color bit;  
--color=always does colorize the match (red) though:

$ cat /usr/share/dict/words | egrep --color '([aeiou][^aeiou]*){8}' | head -15
abdominoanterior
abdominoposterior
aceanthrenequinone
acetabuliferous
acetoacetanilide
acetoamidophenol
acetobromanilide
acetotoluidine
acetylenediurein
achroiocythaemia
Achromobacterieae
acinacifolious
acousticolateral
acromioclavicular
acromiocoracoid

Actually your pattern matches words with 8 vowels -or more-, since it is  
not an anchored match.  Also it counts only lowercase vowels, so any  
8-vowel word with one or more upper-case vowels is missed.  If you only  
want words with exactly 8 vowels you could use:

$ cat /usr/share/dict/words | egrep -i '^[^aeiou]*([aeiou][^aeiou]*){8}$'  
| head -15
abdominoanterior
abdominoposterior
acetabuliferous
acetoamidophenol
acetobromanilide
acetotoluidine
acetylenediurein
achroiocythaemia
Achromatiaceae
acinacifolious
Acipenseroidei
acousticolateral
acromioclavicular
acromiocoracoid
acrotrophoneurosis

$ cat /usr/share/dict/words | egrep '([aeiou][^aeiou]*){8}' | wc -l
    2019
$ cat /usr/share/dict/words | egrep -i '^[^aeiou]*([aeiou][^aeiou]*){8}$'  
| wc -l
    1705

$ egrep --version
egrep (GNU grep) 2.5.1

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Regards,
--Tom.




reply via email to

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