ctrld
1
I have a file "test" with following contents:
cat test
abc
abcd_efg
abc_abc
I want to only grep for abc or abc_ without getting other results, how do I achieve this?
If I use
grep -w abc test
option I get only abc and not abc_.
If I use
egrep "abc|abc_" test
its still printing abcd.
RudiC
2
Try
grep -E "abc$|abc_" file
abc
abc_abc
1 Like
ctrld
3
Thanks Rudic. It was quick
vbe
4
what are they for you?
egrep "abc|abc_" test
Should have given you
abc
abcd_efg
abc_abc
So as we have always asked you to give in your first post, what OS are we dealing with and what shell are you using? to start with...