Unix has several utilities for performing relational algebra-like operations on streams (
cut, additional things with
awk). Is there a grouped aggregate utility readily available (or installable on most Linux distros)?
The goal would be to take a file with some keys in one column and values in another, such as:
foo.txt u1 394082 bar.txt u2 3948 frob.c u1 29322
And output a file that has the unique values of one column, along with some aggregate of the values in another column. For example, the sum of the 3rd column by the 2nd:
$ aggregate --sum=3 --group-by=2 <data u1 423404 u2 3948
Does such a utility exist (Perl, Awk, etc. one-liners don't count), or is it something waiting to be written?