in reply to Alphanumeric sort
No sort required. A one liner:
C:\test>type junk.dat 1208782,abc 406744,def 367455,abc 283191,mps 226159,abc 197688,rxwz 137875,rxwz 115901,abc 107297,def 99213,mps perl -nlE"($n,$k)=split',';$h{$k}+=$n}{say$_,':',$h{$_}for keys%h" jun +k.dat mps:382404 def:514041 abc:1918297 rxwz:335563
But should you need the output sorted:
perl -nlE"($n,$k)=split',';$h{$k}+=$n}{say$_,':',$h{$_}for sort keys%h +" junk.dat abc:1918297 def:514041 mps:382404 rxwz:335563
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Alphanumeric sort
by jffry (Hermit) on Sep 21, 2011 at 22:06 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2011 at 22:10 UTC | |
by jffry (Hermit) on Sep 22, 2011 at 15:06 UTC |