It is currently Tue, 17 May 2022 18:30:50 GMT

Author Message
 grep problem
if I want to grep the strings within a file
which has 3 consecutive occurrences
of the same letter.
ie. "aaa" "bbb"


grep -i '*[a-z][a-z][a-z]*'  filename

but doesn't seen to work...



 Sun, 12 Oct 2003 22:21:12 GMT   
 grep problem
"j a m e s" <> wrote in message

grep -i '\([a-z]\)\1\1' filename

ought to do it - man 5 regexp for more inf.
Peter S Tillier
Opinions expressed are my own and not necessarily those of my employer

 Sun, 12 Oct 2003 23:02:18 GMT   
 grep problem

j a m e s wrote in message <9c6mba$>...
Well, no. "[a-z][a-z]" matches any two alpha characters, not two identical
characters. Bone up on Regular Expressions, rather than just trying what you
think should work because you want it to, and try something like:


 Sun, 12 Oct 2003 23:08:12 GMT   
 grep problem
"j a m e s" <> writes:

Nope. That will match literal * followed by
at least two letters ([a-z]* matches zero
or more letter) - * is different in grep
than in shell filename completion, and
the separate [a-z] patterns are independent,
each may match a different letter.
Also, exactly which letters you'll catch depends on
the locale (you might or might not get some accented
versions, for example).

Assuming reasonably modern (POSIX.2-compliant)
grep, try

grep '\([[:alpha:]]\)\1\1'

Note double brackets. You don't need -i there,
as [[:alpha:]] matches both lower and upper case letters.
In older systems or if you know the locales
used and want to restrict it to ASCII letters,
you can also use

grep -i '\([a-z]\)\1\1'

Tapani Tarvainen

 Mon, 13 Oct 2003 13:33:27 GMT   
 grep problem
<> ???g??l

I see...
Thanks alot.


 Mon, 13 Oct 2003 19:06:42 GMT   
 grep problem

        grep  ".*aaa.*"  filename


On Thu, 26 Apr 2001 02:21:12 +1200, "j a m e s" <> wrote:

 Thu, 16 Oct 2003 11:59:30 GMT   
 grep problem

That will find "aaa", but not "bbb", "ccc", "ddd", etc.  Did you mean
something like:

egrep "aaa|bbb|ccc|...|zzz" filename

?  That would work, but it's quite verbose compared to all the simpler
solutions that have been posted already.

Barry Margolin,
Genuity, Burlington, MA
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 Sat, 18 Oct 2003 03:02:26 GMT   
   [ 7 post ] 

Similar Threads

1. grep problem.

2. grep problems - strange

3. csh/grep problem (on Linux)

4. grep problem in ps aux

5. grep problem

6. Q: Bizarre grep problem

7. sed/grep problems

8. 2K grep problem

9. grep problem

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software