<?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: totalling columns in a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973784#M928313</link>
    <description>Thanks Mr SK,&lt;BR /&gt;I had already worked that part out. I have since got it to work using this, but there must be a better way to format using spaces, which is what I've done. &lt;BR /&gt;&lt;BR /&gt;cat /tmp/myfile| awk '{t1 +=$5;t2 +=$6;t3 +=$7}&lt;BR /&gt;END {printf("Total                                                   %d        %d      %d\n",t1,t2,t3)}' &amp;gt;&amp;gt;/tmp/myfile</description>
    <pubDate>Thu, 15 May 2003 01:30:19 GMT</pubDate>
    <dc:creator>miracle</dc:creator>
    <dc:date>2003-05-15T01:30:19Z</dc:date>
    <item>
      <title>totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973780#M928309</link>
      <description>I am trying to total some columns from some output from an EMC command in a file. &lt;BR /&gt;Here is the output. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                          D E V I C E      G R O U P S                       &lt;BR /&gt;&lt;BR /&gt;                                                       Num of   Num of  Num of&lt;BR /&gt;    Name               Type     Valid  Symmetrix ID    Devices  GK's    BCV's &lt;BR /&gt;&lt;BR /&gt;    goanna1_rdf        RDF2     Yes    000285502576      18        0      18&lt;BR /&gt;    koala1_rdf         RDF1     Yes    000285502576      70        0       0&lt;BR /&gt;    snake11_rdf        RDF1     Yes    000285502576      26        0       0&lt;BR /&gt;    beaver4_rdf        RDF1     Yes    000285502576       5        0       0&lt;BR /&gt;    trouser1_meta      REGULAR  Yes    000285502576       1        0       0&lt;BR /&gt;    monster1_meta1     REGULAR  Yes    000285502576       1        0       1&lt;BR /&gt;    beaver2_reg        REGULAR  Yes    000285502576       4        0       0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I can total one column using:&lt;BR /&gt;$ awk 'BEGIN {total +=5;}&lt;BR /&gt;&amp;gt; END {print "Total ",total}' inputfile &amp;gt;outputfile&lt;BR /&gt;&lt;BR /&gt;When I try to use a similar method it gives a strange total&lt;BR /&gt;$ awk '{F5=F5+$5;F6=F6+$6;F7=F7+$7};END {print F5,F6,F7}'inputfile&lt;BR /&gt;3787 458 03787 458 0&lt;BR /&gt;&lt;BR /&gt;What I really want is totals for each of the last three columns with the numbers appearing underneath.&lt;BR /&gt;AWK would be preferable but any ideas to solve the problem will get you points.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 May 2003 00:12:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973780#M928309</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T00:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973781#M928310</link>
      <description>COL5=0&lt;BR /&gt;COL6=0&lt;BR /&gt;COL7=0&lt;BR /&gt;cat file | while read a b c d e f g&lt;BR /&gt;do&lt;BR /&gt;  COL5=$(($e+$COL5))&lt;BR /&gt;  COL6=$(($f+$COL6))&lt;BR /&gt;  COL7=$(($g+$COL7))&lt;BR /&gt;done</description>
      <pubDate>Thu, 15 May 2003 00:23:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973781#M928310</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2003-05-15T00:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973782#M928311</link>
      <description>When I try this I get the totals correctly but the formatting is not where I want it.&lt;BR /&gt;I want to append to the same input file.&lt;BR /&gt;&lt;BR /&gt;$ awk '{t1 +=$5;t2 +=$6;t3 +=$7}&lt;BR /&gt;&amp;gt; END {print "Total "t1 ,t2 ,t3}' input file &amp;gt;&amp;gt;inputfile&lt;BR /&gt;&lt;BR /&gt;Thanks Michael for your suggestion but it gives an error:&lt;BR /&gt;C+0: bad number</description>
      <pubDate>Thu, 15 May 2003 01:11:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973782#M928311</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T01:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973783#M928312</link>
      <description>Try this instead ..&lt;BR /&gt;$ awk '{F5=F5+$5;F6=F6+$6;F7=F7+$7;} END {print "total:", F5,F6,F7}' inputfile&lt;BR /&gt;You got a bit of syntax problem in your original awk statement. I did not test this but I think it should work.</description>
      <pubDate>Thu, 15 May 2003 01:23:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973783#M928312</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2003-05-15T01:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973784#M928313</link>
      <description>Thanks Mr SK,&lt;BR /&gt;I had already worked that part out. I have since got it to work using this, but there must be a better way to format using spaces, which is what I've done. &lt;BR /&gt;&lt;BR /&gt;cat /tmp/myfile| awk '{t1 +=$5;t2 +=$6;t3 +=$7}&lt;BR /&gt;END {printf("Total                                                   %d        %d      %d\n",t1,t2,t3)}' &amp;gt;&amp;gt;/tmp/myfile</description>
      <pubDate>Thu, 15 May 2003 01:30:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973784#M928313</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T01:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973785#M928314</link>
      <description>In between each of the %d entries, there are number of spaces included to place the totals under columns 5, 6 &amp;amp; 7. Is there a better way?&lt;BR /&gt;&lt;BR /&gt;I don't care if I have to use something else. ... perl ... ? please help</description>
      <pubDate>Thu, 15 May 2003 02:34:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973785#M928314</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T02:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973786#M928315</link>
      <description>You can pad the field with a specify width to get the format you wanted. For example ..&lt;BR /&gt;&lt;BR /&gt;$ cat /tmp/... END {printf("Total 5%d8%d10%d\n",t1,t2,t3)}' .....&lt;BR /&gt;&lt;BR /&gt;and you would get this output.&lt;BR /&gt;&lt;BR /&gt;Total&amp;lt;4 spaces&amp;gt;125&amp;lt;7 spaces&amp;gt;0&amp;lt;9 spaces&amp;gt;19</description>
      <pubDate>Thu, 15 May 2003 03:12:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973786#M928315</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2003-05-15T03:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973787#M928316</link>
      <description>Mr SK&lt;BR /&gt;&lt;BR /&gt;That does not help, it now prints my total line as &lt;BR /&gt;&lt;BR /&gt;Total 5125801019&lt;BR /&gt;</description>
      <pubDate>Thu, 15 May 2003 03:50:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973787#M928316</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T03:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973788#M928317</link>
      <description>Try it this way, by placing the number and % and numerals like this.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;cat file | awk '{t1 +=$5;t2 +=$6;t3 +=$7}&lt;BR /&gt;END {printf("Total %50d %8d %8d\n",t1,t2,t3)}' &amp;gt;&amp;gt;file&lt;BR /&gt;&lt;BR /&gt;The padding for the spacing of the numbers has to be after the % sign not before.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Michael&lt;BR /&gt;"When I have trouble spelling, it's called fat finger syndrome"</description>
      <pubDate>Thu, 15 May 2003 04:07:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973788#M928317</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2003-05-15T04:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973789#M928318</link>
      <description>That works great, I was just wondering if there was a perl solution for this? Can someone help me?</description>
      <pubDate>Thu, 15 May 2003 09:12:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973789#M928318</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-15T09:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973790#M928319</link>
      <description>Well here's one way:&lt;BR /&gt;&lt;BR /&gt;perl -ape '{$a+=$F[4];$b+=$F[5];$c+=$F[6]}END{printf("Total %50d %8d %8d\n",$a,$b,$c)}' yourfile&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Thu, 15 May 2003 09:58:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973790#M928319</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-05-15T09:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973791#M928320</link>
      <description>simply run the awk program provided using the command&lt;BR /&gt;&lt;BR /&gt;awk -f file.awk filename &amp;gt; outputFile&lt;BR /&gt;&lt;BR /&gt;I think this will generate what you want.&lt;BR /&gt;&lt;BR /&gt;= Mike = &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 May 2003 13:20:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973791#M928320</guid>
      <dc:creator>Mike Miller_8</dc:creator>
      <dc:date>2003-05-16T13:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: totalling columns in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973792#M928321</link>
      <description>Thanks Robin for the perl script, that too works well. Thanks Mike for your script as well, but I was trying to limit the padding for the spaces. This case is closed.</description>
      <pubDate>Sun, 18 May 2003 20:45:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/totalling-columns-in-a-script/m-p/2973792#M928321</guid>
      <dc:creator>miracle</dc:creator>
      <dc:date>2003-05-18T20:45:59Z</dc:date>
    </item>
  </channel>
</rss>

