Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Grep for a word or word with underscore

$
0
0
I have a file "test" with following contents:

Code:

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
Code:

grep -w abc test
option I get only abc and not abc_.
If I use
Code:

egrep  "abc|abc_" test
its still printing abcd.

Viewing all articles
Browse latest Browse all 16232

Trending Articles