I have a sample.txt file like this:
abc shk ansjc
def xyz dkksk
ghd ssk jshhd
djsh xyz dsoop
ssd swl jsjdl
I want to print column1 & column2 but column2 can be printed if only the content is matching with "xyz", so the output will be as follows.
abc
def xyz
ghd
djsh xyz
ssd
This is what I tried so far,
awk '$2 == "xyz" { print $1,$2 }' output2.txt || awk '$2 != "xyz" { print $1 }'
Can anyone help me to get this output?