<?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 awk problem..any help.. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834977#M779265</link>
    <description>100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;is there a way to get file like this:&lt;BR /&gt;&lt;BR /&gt;100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 2 2000&lt;BR /&gt;100144 2 2000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;any hints?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 01 Aug 2006 07:53:37 GMT</pubDate>
    <dc:creator>amonamon</dc:creator>
    <dc:date>2006-08-01T07:53:37Z</dc:date>
    <item>
      <title>awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834977#M779265</link>
      <description>100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;is there a way to get file like this:&lt;BR /&gt;&lt;BR /&gt;100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 2 2000&lt;BR /&gt;100144 2 2000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;any hints?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2006 07:53:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834977#M779265</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2006-08-01T07:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834978#M779266</link>
      <description>man uniq</description>
      <pubDate>Tue, 01 Aug 2006 08:00:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834978#M779266</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-08-01T08:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834979#M779267</link>
      <description>associative arrays.&lt;BR /&gt;&lt;BR /&gt;awk '{c[$1]++; t[$1]+=$3}END{for(f in c)printf("%s %d %d\n",f,c[f],t[f])}' input_filename&lt;BR /&gt;&lt;BR /&gt;Did the trick for me, see the evidence:&lt;BR /&gt;&lt;BR /&gt;awk '{c[$1]++; t[$1]+=$3}END{for(f in c)printf("%s %d %d\n",f,c[f],t[f])}'&lt;BR /&gt;100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100136 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100144 1 1000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100144 2 2000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;100136 2 2000&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2006 08:03:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834979#M779267</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2006-08-01T08:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834980#M779268</link>
      <description>I assumed that you wanted the 2nd column to be a count, not a sum of the values.  If you want to sum $2 as well, make this simple change:&lt;BR /&gt;&lt;BR /&gt;awk '{c[$1]+=$2; t[$1]+=$3}END{for(f in c)printf("%s %d %d\n",f,c[f],t[f])}'&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2006 08:18:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834980#M779268</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2006-08-01T08:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834981#M779269</link>
      <description>&lt;!--!*#--&gt;Assuming the duplicate rows will always be adjacent like they were in your example:&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {prev1="BEGIN";prev2=0;prev3=0}&lt;BR /&gt;{if ($1 == prev1) {prev2=prev2 + $2;&lt;BR /&gt; prev3=prev3 + $3;&lt;BR /&gt; continue}&lt;BR /&gt; if (prev1 != "BEGIN") {print prev1 " " prev2 " " prev3}&lt;BR /&gt; prev1=$1;prev2=$2;prev3=$3}&lt;BR /&gt;END {print prev1 " " prev2 " " prev3}' filename&lt;BR /&gt;&lt;BR /&gt;I thought the associated arrays approach was nicer, but there can never be too many examples :)</description>
      <pubDate>Tue, 01 Aug 2006 08:18:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834981#M779269</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-08-01T08:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834982#M779270</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I prefer Perl.&lt;BR /&gt;&lt;BR /&gt;# perl -ne '$line{$_}++;END{for $key (sort keys %line) {@a=split/ /,$key;print join " ",$a[0],$line{$key},$a[2]}}' file&lt;BR /&gt;&lt;BR /&gt;...yields (in sorted output order:&lt;BR /&gt;&lt;BR /&gt;100107 1 1000&lt;BR /&gt;100129 1 1000&lt;BR /&gt;100136 2 1000&lt;BR /&gt;100144 2 1000&lt;BR /&gt;100148 1 1000&lt;BR /&gt;100181 1 1000&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2006 08:21:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834982#M779270</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-01T08:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834983#M779271</link>
      <description>Hi amonamon...try the awk construct below:&lt;BR /&gt;&lt;BR /&gt;# awk '{f[$1]++;s[$1]+=$3} END{for(i in f) print i,f[i],s[i]}' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Tue, 01 Aug 2006 09:01:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834983#M779271</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-08-01T09:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834984#M779272</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sort -n inputfile| uniq -c |awk '{print $1,$2,$4}'&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Tue, 01 Aug 2006 10:01:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834984#M779272</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2006-08-01T10:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834985#M779273</link>
      <description>to Steve Lewis I want 2 col. to be sum not count of values...:)) but thanks for your very useful help :)</description>
      <pubDate>Wed, 02 Aug 2006 00:42:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834985#M779273</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2006-08-02T00:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834986#M779274</link>
      <description>and can U please explain &lt;BR /&gt;awk '{c[$1]+=$2; t[$1]+=$3}END{for(f in c)printf("%s %d %d\n",f,c[f],t[f])}' file &amp;gt;file1&lt;BR /&gt;&lt;BR /&gt;I am new in awk and working with arrays in awk...so this confuses me little...&lt;BR /&gt;&lt;BR /&gt;THANKS a LOOTT &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Aug 2006 01:38:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834986#M779274</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2006-08-02T01:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834987#M779275</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;read 'man awk' as first information - you'll find a section for ARRAYs.&lt;BR /&gt;For short:&lt;BR /&gt;&lt;BR /&gt;c[$1]+=$2&lt;BR /&gt;In array c add the value of second field ($2) to the array element indexed by the value of the first field ($1). Note that awk uses associative arrays, i.e. an index needs not to be a number.&lt;BR /&gt;&lt;BR /&gt;for(f in c)&lt;BR /&gt;Looop through all indices of the array c using f as current idex value. Thre will be no sorting of indices when running through the loop.&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Aug 2006 05:23:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834987#M779275</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-08-02T05:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem..any help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834988#M779276</link>
      <description>Thanks Peter...I read about awk..but those arrays are confusing me little...thank U for your help..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Aug 2006 06:10:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem-any-help/m-p/3834988#M779276</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2006-08-02T06:10:12Z</dc:date>
    </item>
  </channel>
</rss>

