You'll have to do the sorting yourself, but here's what I came up with (just a quick hack):
#!/usr/bin/perl -w foreach (<DATA>) { next if /^#/; # Oops! Forgot this the first time :( my @results = split; $type = $1 if $results[3] =~ /(\.\w+)$/; $code = $results[4]; $output{$type}{$code}++; } foreach $type_key (keys %output) { foreach $code_key (keys %{$output{$type_key}}) { print "$type_key\t$code_key\t$output{$type_key}{$code_key}\n"; } } __DATA__ 00:00:29 192.168.20.50 GET /Plastic/ProductTop.html 200 00:00:29 192.168.20.50 GET /Plastic/images/ProductNavTopRt.jpg 304 00:00:29 192.168.20.50 GET /plastic/ProductNav.html 200 00:00:29 192.168.20.50 GET /plastic/images/ProductNav1b.jpg 304 00:00:29 192.168.20.50 GET /main.html 202
The output was as follows:
.html 200 2 .html 202 1 .jpg 304 2
Cheers,
Ovid

Update: I'm seeing responses to this node which are almost, but not quite correct. If you read the question carefully, you'll notice that the type and code are not synonymous. You can't just lump them together and ++, nor can you simply count the instances of each type. Each type can have multiple codes and it's the instances of each code per type that the poster as looking for.


In reply to Re: Parsing a log file by Ovid
in thread Parsing a log file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.