<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re:  find the count in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387948#M714031</link>
    <description>Rahul,&lt;BR /&gt;&lt;BR /&gt;no problems and thanks for taking the time to award points!&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
    <pubDate>Mon, 27 Sep 2004 15:46:29 GMT</pubDate>
    <dc:creator>Michael Schulte zur Sur</dc:creator>
    <dc:date>2004-09-27T15:46:29Z</dc:date>
    <item>
      <title>find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387939#M714022</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have parsed a number of files for the value on a particular field and stored it in a file. Now I want to know the count of each pattern that is stored in the file. For example, the entries in the file has&lt;BR /&gt;&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;def&lt;BR /&gt;xyz&lt;BR /&gt;xyz&lt;BR /&gt;123&lt;BR /&gt;123&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;and so on. I want to get the count of the occurance of each values. Say, abc - 3 times, 123 - 5 times etc.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help me&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Rahul</description>
      <pubDate>Mon, 27 Sep 2004 14:14:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387939#M714022</guid>
      <dc:creator>Rahul_13</dc:creator>
      <dc:date>2004-09-27T14:14:41Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387940#M714023</link>
      <description>grep with -c option will tell you the count&lt;BR /&gt;&lt;BR /&gt;# grep -c "abc" inputfile&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 14:18:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387940#M714023</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-09-27T14:18:06Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387941#M714024</link>
      <description>Bingo! - Sundar has it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Another way , pipe to wc&lt;BR /&gt;&lt;BR /&gt;grep "abc" somefile |wc&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 27 Sep 2004 14:28:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387941#M714024</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-09-27T14:28:16Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387942#M714025</link>
      <description>grep pattern &lt;FILE name=""&gt; | wc -l &lt;BR /&gt;&lt;BR /&gt;this is easiest way to acheive this. &lt;BR /&gt;And if you know pattern, you can do some more things of your linking, like &lt;BR /&gt;&lt;BR /&gt;count=1&lt;BR /&gt;cat filename | while read line &lt;BR /&gt;echo $line &lt;BR /&gt;if [ $line = $pattern ] &lt;BR /&gt;((count=count+1))&lt;BR /&gt;done&lt;BR /&gt;something like above you may like to do. &lt;BR /&gt;Hope the above helps&lt;BR /&gt;Prashant&lt;/FILE&gt;</description>
      <pubDate>Mon, 27 Sep 2004 14:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387942#M714025</guid>
      <dc:creator>Prashant Zanwar_4</dc:creator>
      <dc:date>2004-09-27T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387943#M714026</link>
      <description>Hi,&lt;BR /&gt;if the lines are adjacant as in your example, you can also try the uniq command, e.g.&lt;BR /&gt;# uniq -c &lt;INFILE&gt;&lt;BR /&gt;  3 abc&lt;BR /&gt;   1 def&lt;BR /&gt;   2 xyz&lt;BR /&gt;   2 123&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;/INFILE&gt;</description>
      <pubDate>Mon, 27 Sep 2004 14:42:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387943#M714026</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-09-27T14:42:23Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387944#M714027</link>
      <description>The general case solution is &lt;BR /&gt;  sort file | uniq -c&lt;BR /&gt;to get a count for each unique line in file.&lt;BR /&gt;&lt;BR /&gt;You can push that through one more sort to order the patterns by frequency.&lt;BR /&gt;  sort file | uniq -c | sort -bn&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 15:27:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387944#M714027</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-09-27T15:27:49Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387945#M714028</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The values can be anything and it is not known to me so that I could serach for the pattern and do a count of that.&lt;BR /&gt;&lt;BR /&gt;What I need to do is find the count of the occurance of each values which are present in the file. The file also has few blank lines.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Rahul&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 15:27:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387945#M714028</guid>
      <dc:creator>Rahul_13</dc:creator>
      <dc:date>2004-09-27T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387946#M714029</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;what about&lt;BR /&gt;grep -v "^ *$" file | sort | uniq -c&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 15:36:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387946#M714029</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-09-27T15:36:05Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387947#M714030</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I tried &lt;BR /&gt;&lt;BR /&gt;sed '/^*$/d' &amp;lt; file|sort|uniq -c &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;and it worked.&lt;BR /&gt;&lt;BR /&gt;Thanks to everyone.&lt;BR /&gt;&lt;BR /&gt;-Anand.</description>
      <pubDate>Mon, 27 Sep 2004 15:42:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387947#M714030</guid>
      <dc:creator>Rahul_13</dc:creator>
      <dc:date>2004-09-27T15:42:35Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387948#M714031</link>
      <description>Rahul,&lt;BR /&gt;&lt;BR /&gt;no problems and thanks for taking the time to award points!&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 15:46:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387948#M714031</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-09-27T15:46:29Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387949#M714032</link>
      <description>YOu can do &lt;BR /&gt;&lt;BR /&gt;filename=yourfilename&lt;BR /&gt;cat $filename | sort | uniq &amp;gt;&amp;gt; /tmp/strings.uniq&lt;BR /&gt;&lt;BR /&gt;cat /tmp/strings.uniq | while read line &lt;BR /&gt;do&lt;BR /&gt;grep -c  $line $filename&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;for taking into accoung the blank lines, simply do&lt;BR /&gt;&lt;BR /&gt;grep -c ^$  $filename&lt;BR /&gt;&lt;BR /&gt;Hope above helps&lt;BR /&gt;&lt;BR /&gt;Prashant</description>
      <pubDate>Mon, 27 Sep 2004 15:54:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387949#M714032</guid>
      <dc:creator>Prashant Zanwar_4</dc:creator>
      <dc:date>2004-09-27T15:54:16Z</dc:date>
    </item>
    <item>
      <title>Re:  find the count</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387950#M714033</link>
      <description>Remove blank lines by identfying pattern ^$ and do sort and uniq will give results there.&lt;BR /&gt;&lt;BR /&gt; By simply,&lt;BR /&gt; &lt;BR /&gt;  sed 's/^$//g' &lt;INPUTFILE&gt; | sort -nb | uniq -c&lt;BR /&gt;&lt;BR /&gt;  -nb used to remove leading blanks and compare them there.&lt;BR /&gt; &lt;BR /&gt;&lt;/INPUTFILE&gt;</description>
      <pubDate>Mon, 27 Sep 2004 23:26:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-the-count/m-p/3387950#M714033</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-27T23:26:09Z</dc:date>
    </item>
  </channel>
</rss>

