I have a file that looks like this:
I would like to remove duplicate lines using the following:
However I only want to remove duplicates if $1 equals grape.
Desired output:
Not sure where to go from there..
The log is if $1 equals "grape" and I have seen $2 before then don't print.
Code:
apple4 yellow
apple1 red
apple6 blue
apple3 green
grape red
grape purple
apple68 yellow
apple32 red
apple98 orange
grape yellow
I would like to remove duplicate lines using the following:
Code:
awk '!x[$2]++'
However I only want to remove duplicates if $1 equals grape.
Desired output:
Code:
apple4 yellow
apple1 red
apple6 blue
apple3 green
[s]grape red[/s]
grape purple
apple68 yellow
apple32 red
apple98 orange
[s]grape yellow[/s]
Not sure where to go from there..
The log is if $1 equals "grape" and I have seen $2 before then don't print.