<?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: BC to add items in a collumn in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040688#M754372</link>
    <description>cat filename |xargs echo|sed "s/ / + /g"|bc&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Tue, 17 Apr 2007 10:27:47 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2007-04-17T10:27:47Z</dc:date>
    <item>
      <title>BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040683#M754367</link>
      <description>I have a file that looks like this,&lt;BR /&gt;&lt;BR /&gt;143413413&lt;BR /&gt;412342346&lt;BR /&gt;432434877&lt;BR /&gt;434978867&lt;BR /&gt;432654657&lt;BR /&gt;&lt;BR /&gt;How would I use bc to cat this file and add the numbers?</description>
      <pubDate>Tue, 17 Apr 2007 09:50:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040683#M754367</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2007-04-17T09:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040684#M754368</link>
      <description>Hi,&lt;BR /&gt;why bc ?&lt;BR /&gt;&lt;BR /&gt;See earlier threads:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=22594" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=22594&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1080308" target="_blank"&gt;https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1080308&lt;/A&gt;</description>
      <pubDate>Tue, 17 Apr 2007 09:54:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040684#M754368</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-04-17T09:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040685#M754369</link>
      <description>Sorry, I can not use awk or perl</description>
      <pubDate>Tue, 17 Apr 2007 09:56:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040685#M754369</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2007-04-17T09:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040686#M754370</link>
      <description>Hi,&lt;BR /&gt;found on an old website:&lt;BR /&gt;#!/bin/ksh &lt;BR /&gt;TOTAL=0 &lt;BR /&gt;for NUMBER in `cat &lt;FILE&gt;` &lt;BR /&gt;do &lt;BR /&gt;     TOTAL=`echo $NUMBER + $TOTAL |bc -l` &lt;BR /&gt;done &lt;BR /&gt;echo $TOTAL&lt;/FILE&gt;</description>
      <pubDate>Tue, 17 Apr 2007 10:07:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040686#M754370</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-04-17T10:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040687#M754371</link>
      <description>Here is one approach:&lt;BR /&gt;&lt;BR /&gt;TF="/var/tmp/TF${$}"&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${TF}' 0 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;INFILE=myfile&lt;BR /&gt;echo "a=0" &amp;gt; ${TF}&lt;BR /&gt;cat ${INFILE} | while read N&lt;BR /&gt;  do&lt;BR /&gt;     echo "a+=${N}" &amp;gt;&amp;gt; ${TF}&lt;BR /&gt;  done&lt;BR /&gt;echo "a" &amp;gt;&amp;gt; ${TF}&lt;BR /&gt;TOT=$(bc &amp;lt; ${TF})&lt;BR /&gt;echo "Total: ${TOT}"</description>
      <pubDate>Tue, 17 Apr 2007 10:15:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040687#M754371</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-04-17T10:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040688#M754372</link>
      <description>cat filename |xargs echo|sed "s/ / + /g"|bc&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 17 Apr 2007 10:27:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040688#M754372</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2007-04-17T10:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040689#M754373</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;a solution with dc:&lt;BR /&gt;&lt;BR /&gt;(sed '2,$s/$/+/' /tmp/num; print p) | dc&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 17 Apr 2007 10:56:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040689#M754373</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-17T10:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040690#M754374</link>
      <description>Yet another way of doing the same thing...&lt;BR /&gt;&lt;BR /&gt;# p=0; while read l;do p=$(echo "$l + $p" | bc); done &amp;lt; infile;echo $p&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Tue, 17 Apr 2007 11:41:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040690#M754374</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-04-17T11:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040691#M754375</link>
      <description>&amp;gt;&amp;gt; Sorry, I can not use awk or perl &lt;BR /&gt;&lt;BR /&gt;Unacceptable.&lt;BR /&gt;&lt;BR /&gt;Please explain.&lt;BR /&gt;&lt;BR /&gt;Sure you can.&lt;BR /&gt;&lt;BR /&gt;Apparently you can not use BC either, so why not use / learn somethign much more versatile and useful in the long run.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 12:50:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040691#M754375</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-04-17T12:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040692#M754376</link>
      <description>.</description>
      <pubDate>Tue, 17 Apr 2007 12:56:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040692#M754376</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2007-04-17T12:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: BC to add items in a collumn</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040693#M754377</link>
      <description>Randall,&lt;BR /&gt;&lt;BR /&gt;You may not have liked my answer and that's ok, but please humor me and explain why it had to be 'bc' and why you had to 'cat' the file. I'm curious and always eager to learn!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 13:58:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc-to-add-items-in-a-collumn/m-p/5040693#M754377</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-04-17T13:58:49Z</dc:date>
    </item>
  </channel>
</rss>

