in reply to Counting lines by content

You could handle this with a simple two-liner
perl -F: -e 'END { print "$_ $c{$_}\n" for keys %c }' \ -ane '$c{$F[1]}++'
See perlrun for more info on perl's command-line options.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Counting lines by content
by willa (Acolyte) on Oct 09, 2002 at 11:35 UTC
    Thanks - I also need to make sure there are no duplicates in the third field. I assume this is easy too...
      This will count the second field ignoring duplicates
      perl -F: -e 'END { print "$_ $c{$_}\n" for keys %c }' \ -ane '$c{$F[1]}++ unless $d{"@F[1,2]"}++'
      I assume this is what you meant no duplicates in the third field.
      HTH

      _________
      broquaint

        Thanks! Works a treat!