My file has this structure:
HELLO h e l lo
HELLO(2) h ee l lo
HELLOMUM h e l ll m um
HELLO-FATHER h e llo fa th er
HOME h o m e
HONEY h o ne y
HONEY(2) ho nei y
HONEY(3) h o ney
HONEYMOON ho ney m o o n
HONEY-MOON h o ne y moo n
I would like, while looking for the word HELLO, for example, to extract only the lines relatives to the words HELLO and HELLO(2). Same thing if I am looking for the word HONEY, I would like to have only the lines relative to HONEY, HONEY(2) and HONEY(3).
I am using
grep -w "HELLO" file.txt
but this gives me back for HELLO, for example, also the lines relative to HELLOMUM and HELLO-FATHER.
Thank you in advance.
I guess this should work for you.
tested below: