<?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: Adding a column of numbers in a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036202#M757941</link>
    <description>Thanks Peter for quick response i'll try it.&lt;BR /&gt;&lt;BR /&gt;As part of the same script all these numbers are generated into a file. I want to total the number in them and if it's above a certain treshold it will mail me.&lt;BR /&gt;&lt;BR /&gt;So will i cat the file with all numbers in it and pipe it to your awk command you supplied?&lt;BR /&gt;&lt;BR /&gt;Paddy</description>
    <pubDate>Mon, 26 Mar 2007 06:08:52 GMT</pubDate>
    <dc:creator>Paddy O'Connell</dc:creator>
    <dc:date>2007-03-26T06:08:52Z</dc:date>
    <item>
      <title>Adding a column of numbers in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036200#M757939</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm looking to total up all the numbers in a file as part of a shell script.&lt;BR /&gt;&lt;BR /&gt;sample file is like below, now i'll have hundreds of numbers&lt;BR /&gt;&lt;BR /&gt;68&lt;BR /&gt;8&lt;BR /&gt;2&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Paddy</description>
      <pubDate>Mon, 26 Mar 2007 05:57:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036200#M757939</guid>
      <dc:creator>Paddy O'Connell</dc:creator>
      <dc:date>2007-03-26T05:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a column of numbers in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036201#M757940</link>
      <description>Paddy,&lt;BR /&gt;you don't mention a preference for solution, so here is one in awk:&lt;BR /&gt;awk 'BEGIN {total=0;} {total=total+$1;} END {print total,"\n";}' data.lis&lt;BR /&gt;&lt;BR /&gt;Please also read:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; on how to reward any useful answers given to your questions.</description>
      <pubDate>Mon, 26 Mar 2007 06:01:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036201#M757940</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-26T06:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a column of numbers in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036202#M757941</link>
      <description>Thanks Peter for quick response i'll try it.&lt;BR /&gt;&lt;BR /&gt;As part of the same script all these numbers are generated into a file. I want to total the number in them and if it's above a certain treshold it will mail me.&lt;BR /&gt;&lt;BR /&gt;So will i cat the file with all numbers in it and pipe it to your awk command you supplied?&lt;BR /&gt;&lt;BR /&gt;Paddy</description>
      <pubDate>Mon, 26 Mar 2007 06:08:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036202#M757941</guid>
      <dc:creator>Paddy O'Connell</dc:creator>
      <dc:date>2007-03-26T06:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a column of numbers in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036203#M757942</link>
      <description>It's ok Peter, i removed the data.lis you put at the end and it's set to cat the file and pipe to awk.&lt;BR /&gt;Thanks for that&lt;BR /&gt;&lt;BR /&gt;Paddy</description>
      <pubDate>Mon, 26 Mar 2007 06:13:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036203#M757942</guid>
      <dc:creator>Paddy O'Connell</dc:creator>
      <dc:date>2007-03-26T06:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a column of numbers in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036204#M757943</link>
      <description>Paddy,&lt;BR /&gt;my test was:&lt;BR /&gt;$ cat a.lis&lt;BR /&gt;1.1&lt;BR /&gt;2.5&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;$ level=`awk 'BEGIN {total=0;} {total=total+$1;} END {print total,"\n";}' a.lis`&lt;BR /&gt;$ echo $level&lt;BR /&gt;10.6&lt;BR /&gt;$ &lt;BR /&gt;Just to check that it worked with float as well.&lt;BR /&gt;&lt;BR /&gt;In your case you can use the $level bit to then decide whether to mail. Something like:&lt;BR /&gt;&lt;BR /&gt;level=`awk ....&lt;BR /&gt;if [ $level -gt 75 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Level is $level" | mailx -s "level reached" usr@aol.com &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Mar 2007 06:15:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-a-column-of-numbers-in-a-file/m-p/5036204#M757943</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-26T06:15:24Z</dc:date>
    </item>
  </channel>
</rss>

