<?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: Awk sum script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560493#M679041</link>
    <description>&amp;gt;OldSchool: let sum=$sum+$incr&lt;BR /&gt;&lt;BR /&gt;You may want to just use:&lt;BR /&gt;(( sum += incr ))</description>
    <pubDate>Fri, 08 Jan 2010 16:54:34 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2010-01-08T16:54:34Z</dc:date>
    <item>
      <title>Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560487#M679035</link>
      <description>I have text file &lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;I would like to use awk to sum up the total of these numbers and output the number 6.&lt;BR /&gt;&lt;BR /&gt;Is this possible in awk?</description>
      <pubDate>Fri, 08 Jan 2010 00:55:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560487#M679035</guid>
      <dc:creator>Eugene Matusovsky</dc:creator>
      <dc:date>2010-01-08T00:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560488#M679036</link>
      <description>Hi Eugene,&lt;BR /&gt;&lt;BR /&gt;# cat a1&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN {sum=0}{sum+=$1} END {print sum}' &amp;lt; a1&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;Hope this helps..!</description>
      <pubDate>Fri, 08 Jan 2010 01:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560488#M679036</guid>
      <dc:creator>R.K. #</dc:creator>
      <dc:date>2010-01-08T01:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560489#M679037</link>
      <description>awk '{ s += $1 } END { print "sum: ", s }' abc&lt;BR /&gt;&lt;BR /&gt;abc is file name.&lt;BR /&gt;&lt;BR /&gt;BR,&lt;BR /&gt;Kapil+</description>
      <pubDate>Fri, 08 Jan 2010 03:07:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560489#M679037</guid>
      <dc:creator>Kapil Jha</dc:creator>
      <dc:date>2010-01-08T03:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560490#M679038</link>
      <description>&amp;gt;I would like to use awk to sum&lt;BR /&gt;&lt;BR /&gt;awk(1) has an example that does that.</description>
      <pubDate>Fri, 08 Jan 2010 09:10:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560490#M679038</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-01-08T09:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560491#M679039</link>
      <description>This all great! Thanks so much for everyone's help. I'm also considering doing the sum in ksh/bash only...Is this possible?&lt;BR /&gt;&lt;BR /&gt;Thank You</description>
      <pubDate>Fri, 08 Jan 2010 15:54:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560491#M679039</guid>
      <dc:creator>Eugene Matusovsky</dc:creator>
      <dc:date>2010-01-08T15:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560492#M679040</link>
      <description>sure...for integer math&lt;BR /&gt;&lt;BR /&gt;typeset i sum&lt;BR /&gt;typeset i incr&lt;BR /&gt;&lt;BR /&gt;sum=0&lt;BR /&gt;echo $sum&lt;BR /&gt;&lt;BR /&gt;while read incr;&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;let sum=$sum+$incr&lt;BR /&gt;echo $sum&lt;BR /&gt;done &amp;lt; yourfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;there are also methods involving bc that will do reals/floats</description>
      <pubDate>Fri, 08 Jan 2010 16:14:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560492#M679040</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2010-01-08T16:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560493#M679041</link>
      <description>&amp;gt;OldSchool: let sum=$sum+$incr&lt;BR /&gt;&lt;BR /&gt;You may want to just use:&lt;BR /&gt;(( sum += incr ))</description>
      <pubDate>Fri, 08 Jan 2010 16:54:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560493#M679041</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-01-08T16:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Awk sum script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560494#M679042</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Thanks so much for everyone's help. I'm also considering doing the sum in ksh/bash only...Is this possible?&lt;BR /&gt;&lt;BR /&gt;Yes, as OldSchool showed you, the shell can do this.  Beware that in HP-UX, the Posix ('/usr/bin/sh') shell limits you to 32-bit arithmetic.  If you are running 11.23 or later, the Korn shell ('/usr/bin/ksh') will support 64-bit arithmetic.&lt;BR /&gt;&lt;BR /&gt;Running OldSchool's code and adding the numbers found in an input file:&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2147483648&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;...yields:&lt;BR /&gt;&lt;BR /&gt;-2147483642&lt;BR /&gt;&lt;BR /&gt;Changing to a Korn shell yields the correct value:&lt;BR /&gt;&lt;BR /&gt;2147483654&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also:&lt;BR /&gt;&lt;BR /&gt;typeset i sum&lt;BR /&gt;&lt;BR /&gt;...should be:&lt;BR /&gt;&lt;BR /&gt;typeset -i sum&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jan 2010 17:16:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sum-script/m-p/4560494#M679042</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-01-08T17:16:51Z</dc:date>
    </item>
  </channel>
</rss>

