Use the -o flag to only see the part of pattern you are interested in.
Let’s return to our handy dandy test.txt file with the following content:
sad
happy
awake
coffee
work
schoolIf we grep for “wake” we will see the entire line:
$ grep "wake" test.txt
awakeUsing the -o flag, the output is exactly what we are searching for:
$ grep -o "wake" test.txt
wake