I have a file like this example:
NDUFAF7,0.216216,
ESRRA,0.0178571,
HS3ST1,0.027027,
HS3ST1,0,
HS3ST1,0.0833333,
ESRRA,0.214286,
NDUFAF7,0.0824742,
ESRRA,0.0810811,
NDUFAF7,0,
in which there are 2 comma separated
columns. in the 1st column some rows are repeated. I want to keep only one of every repeated row based on the value in the 2nd column
. in fact I want to keep the one with the biggest value in the 2nd row. the output for above example would be (which is tab separated
):
NDUFAF7 0.216216
HS3ST1 0.0833333
ESRRA 0.214286
I tried the following code in awk
but did not return what I want.
awk -F "," '{ if($2 >= $2) { print }}' file_name
do you know how to fix it?