Этот простой awk
должен помочь вам здесь.
awk 'FNR==NR{a[$2]=(a[$2]>$1?a[$2]:$1);next} a[$2]==$1' Input_file Input_file
Объяснение:
awk '
FNR==NR{ ##Checking condition here FNR==NR which will be TRUE when first time Input_file is being read.
a[$2]=(a[$2]>$1?a[$2]:$1) ##Creating an array named a whose index is $2 and value is depending upon condition if its value is greater than $1 then leave it as it is else replace its value with current $1 value.
next ##next is awk out of box keyword which will skip all further statements.
}
a[$2]==$1 ##This statement will be executed when 2nd time Input_file is being read and checking condition if value of a[$2] is equal to first field of current line, if yes then print that line.
' Input_file Input_file ##Mentioning Input_file name 2 times here.