Regular Expression symbol "?" not working in shell


#1

HI ,

I have one file with the following data.

test
best
+see
done++
feett
ttesingt
vino+

i want the output as below

best
+see
done++
vino+

I am using the below command for the output

egrep ‘t?’ filename.

We know that the meaning of “?” is zero or one occurrence of previous character. So in my case t is optional if it present it has only one t but i am getting all lines as output.

Please help me what i am doing mistake


#2

hi
you can use :
egrep ‘t?’ filename | grep -v tt | grep -v *t

hope i helped