1753970 Members
7361 Online
108811 Solutions
New Discussion юеВ

egrep question

 
Alan Wyskowski
Frequent Advisor

egrep question

Can someone explain to me why this would match. To me is should not match the pattern it did. Thanks.


$ egrep "^Subject:.*CMR*" badfile (did find that string)

Subject: PVCS Dimensions Baseline WNP:SCM_WNP_BL1_051503 is now in your pending list $ exit
3 REPLIES 3
Rodney Hills
Honored Contributor

Re: egrep question

Because CMR* means CM followed by ZERO or more R's. So SCM matches that portion.

HTH

-- Rod Hills
There be dragons...
Vicente Sanchez_3
Respected Contributor

Re: egrep question

Hello,

Probably is the (.), as special char. If the string you are looking for contains this char, insert a \ before:

egrep "^Subject:\.*CMR*" badfile

Regards, Vicente.
Sachin Patel
Honored Contributor

Re: egrep question

Hi Alan,

could you more specific? how is your badfile look like.

Looks like you are trying to match line start with Subject which has CMR at any place.

Here is whaat happen when I try
hpc-ps3{sachin}% echo "Subject: jadklfj iewui CMR jakdjkl" > badfile

hpc-ps3{sachin}% egrep "^Subject:.*CMR*" badfile
Subject: jadklfj iewui CMR jakdjkl

sachin
Is photography a hobby or another way to spend $