awk 'NR==FNR{a[$1]=1;next}($1 in a) && $2 > a[$1]{a[$1]=$2}END{for(i in a)print i, a}' file1 file2
Hi Franklin52, thanks a lot for the reply. Its working just fine.
However, I also have another set of files which are similar to the above mentioned but slightly different orientation. And I couldnt apply your code to them. Here are the files.
As you can see there are 5 columns now in file2. Match the column of file1 with fifth column of file2 and print out the complete lines in file2 with corresponding highest value in column2 of file2. If the values are same and no highest value, just print the first line of matching.
desired output