egrep bug

View: New views
2 Messages — Rating Filter:   Alert me  

egrep bug

by Jonathan Bronson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Parent Message unknown Re: egrep bug

by Tom Hageman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi  Jonathan,

In article <mailman.10013.1257294452.2239.bug-gnu-utils@...>, 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.