in reply to Re: Reading from text file
in thread Reading from text file

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

Are we going for golf?    :-)

echo "China:wd:2 Japan:wd:6 China:sg:2 Japan:sg:10 China:kng:70 Thailand:kng:6" | perl -F: -le'push@{$h{$F[0]}},$F[2]}{$,=":";print$_, +@{$h{$_}}for sort keys%h' China:2:2:70 Japan:6:10 Thailand:6