The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-19-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
This works:
Code:
 egrep '^(a)(a)?' filename
test:
Code:
kcsdev:/home/jmcnama> cat filename
a
aa
aaa
aaaa
aaaaa
aaaaaa
123456
ABCDEF



kcsdev:/home/jmcnama> egrep '^(a)(a)?' filename
a
aa
aaa
aaaa
aaaaa
aaaaaa
Note:
Code:
 egrep '^(a)+$' filename
is closer to correct - correct being 'find a line of any non-zero length that has only the letter a'

Last edited by jim mcnamara; 05-19-2006 at 04:36 PM..