Given a file with two columns:
Id ht
510 69
510 67
510 65
5l0 62
510 59
601 29
601 26
601 21
601 20
I need a way to coalesce all rows with the same ID into one that has an average height. In this case, (69 + 67 + 65 + 62 + 59) / 5 = 64 and (29 + 26 + 21 + 20) / 4 = 24, so the output should be:
Id Avg.ht
510 64
601 24
How can I do that using sed/awk/perl?