Extract only whole word using grep

The problem you are facing is that a dash (-) is considered by grep as a word delimiter.

You should try this command :

grep '\sDUSP1\s' file

to ensure that there's spaces around your word.
Or use words boundaries :

grep '\bDUSP1\b' file

adding to what sputpick said, it could either be that or:

grep '\sDUSP1$' file 

if the DUSP1 is the end of the line.


If you want to grep exactly the whole word, you can use word boundaries like this:

grep '\bDUSP1\b'

This matches for the exact word at the beginning and at the end.