Use the -w flag to match on whole words.
Recall our test.txt file with the following content:
sad
happy
awake
coffee
work
schoolSuppose we want to search for “wake”. We would do the following:
$ grep "wake" test.txt
awakeUsing the -w flag will give us all the lines that contain “wake” as
a whole word and not just a part of word.
$ grep -w "wake" test.txtIn this case, the grep command returns nothing.