in reply to Counting lines starting with a unique string
perl -ne 'END{print"$v\t$k\n"while($k,$v)=each%h} $h{substr$_,0,5} +++' file perl -ne 'END{printf"%7d %s\n",$h{$_},$_for keys%h} $h{substr$_,0, +5}++' file perl -pe '$h{substr$_,0,5}++ }{ print"$h{$_}\t$_\n"for+keys%h' fil +e
If you have GNU uniq then you can do the following: sort file | uniq -w5 -c
However, the -w option isn't part of classical uniq.
--
John.
|
|---|