<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Sat, 13 Jun 2026 15:35:46 +0000</lastBuildDate>
    <item>
      <title>(Bash) Awk Script to count # of occurences of fields in a file - webapplications</title>
      <link>https://snipplr.com/view/16533/awk-script-to-count--of-occurences-of-fields-in-a-file</link>
      <description>&lt;p&gt;Use to quickly list  the unique fields in a file AND the number of times the field occurs   &#13;
e.g. Count how times a resource (eg image) has been resulted in a 404 status by examining the IIS logs.&#13;
&#13;
eg assuming this is the input file: **input.txt** and the source script below is in **count.awk**  &#13;
&#13;
2009-06-26 GET /presources/ebooks/images/step3.gif 404  &#13;
2009-06-26 GET /images/20090000/20094617.gif 404  &#13;
2009-06-26 GET /presources/ebooks/images/digital_rarrow.gif 404  &#13;
2009-06-26 GET /images/19480000/19482901.gif 404  &#13;
2009-06-26 GET /images/33110000/33111321.gif 404  &#13;
2009-06-26 GET /presources/ebooks/images/step3.gif 404  &#13;
2009-06-26 GET /presources/ebooks/images/step1.gif 404  &#13;
2009-06-26 GET /presources/ebooks/images/step3.gif 404  &#13;
2009-06-26 GET /images/20090000/20094487.gif 404  &#13;
2009-06-26 GET /presources/ebooks/images/step1.gif 404  &#13;
&#13;
executing   &#13;
&#13;
     awk -f count.awk input.txt &#13;
&#13;
will yield  &#13;
&#13;
1 /images/33110000/33111321.gif   &#13;
2 /presources/ebooks/images/step1.gif   &#13;
3 /presources/ebooks/images/step3.gif  &#13;
1 /presources/ebooks/images/digital_rarrow.gif  &#13;
1 /images/20090000/20094487.gif  &#13;
1 /images/19480000/19482901.gif  &#13;
1 /images/20090000/20094617.gif&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jul 2009 01:37:23 UTC</pubDate>
      <guid>https://snipplr.com/view/16533/awk-script-to-count--of-occurences-of-fields-in-a-file</guid>
    </item>
  </channel>
</rss>
