I have the following file:
A B 1990 A C 2001 A C 2013 A B 2001 B C 2013 A D 2001 A D 2014
I need to count duplicate pairs (in the 1st and 2nd column) and to each such pair assign the lowest value from the 3rd column. For my toy file the output should be:
A B 2 1990 A C 2 2001 A D 2 2001 B C 1 2013
For example, pair
A B occurs two times, first time with value 1990 and second time with value 2001, because 1990 < 2001 we assign 1990 to this count.
I wonder how to do that with Linux tools (Bash, AWK, Perl). Any ideas / pointers would be greatly appreciated.