perl -aF: -ne 'chomp @F;push @{$h{$F[0]}},$F[2]}{print join(":",$_,@{$h{$_}}),"\n" for sort keys %h'