Experts,
Here is my question.
I have got file like below
# cat file
XYZb,24,26,6
XYZc,24,26,6
XYZe,24,25,5
XYZf,23,29,5
XYZi,16,25,5
XYZj,24,26,7
XYZn,17,23,4
XYZz,23,29,5
Now, I want to print the line's Column1[delimitor is ,] whose Column 3 is the max of all.
My code is
awk -F',' 'BEGIN {max = 0;} {if ($3>max) {max=$3;server=$1}} END {print server}' file
But, If there are more than 1 row contain the same max value, my snippet is printing only the last one. Please help.
Here my expected output is XYZf,XYZz.
PS: I want to get this accomplished with awk