<?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: using awk to calculate in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003930#M98466</link>
    <description>Or simply use the long form instead of the compact one to avoid confusion i.e.&lt;BR /&gt;&lt;BR /&gt;cat mydf.out |awk 'BEGIN {tot=0} {tot=tot+$1} END {print tot}'</description>
    <pubDate>Mon, 18 Sep 2006 13:09:17 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2006-09-18T13:09:17Z</dc:date>
    <item>
      <title>using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003926#M98462</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;I am attempting to use awk to calculate some numbers.  I have put the figures into a file from the df command:&lt;BR /&gt;&lt;BR /&gt;# cat mydf.out&lt;BR /&gt;&lt;BR /&gt;2424&lt;BR /&gt;4246432&lt;BR /&gt;32434672&lt;BR /&gt;323&lt;BR /&gt;5432521&lt;BR /&gt;43433&lt;BR /&gt;etc etc&lt;BR /&gt;&lt;BR /&gt;I want to add them all together with the total being displayed at the end -  have attempted with no luck:&lt;BR /&gt;&lt;BR /&gt;cat mydf.out |awk 'BEGIN {tot=0} {tot=+$1} END {print tot}'&lt;BR /&gt;&lt;BR /&gt;how can I do this using awk please?&lt;BR /&gt;&lt;BR /&gt;many thnaks&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:59:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003926#M98462</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-09-18T10:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003927#M98463</link>
      <description>Hi Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;# awk '{a+=$1} END {print a}' mydf.out&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Mon, 18 Sep 2006 11:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003927#M98463</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-09-18T11:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003928#M98464</link>
      <description>I use the following script to calculate total used space from bdf output.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;BDFMEGS=/usr/local/bin/bdfmegs&lt;BR /&gt;if [ ! -x $BDFMEGS ]&lt;BR /&gt;then&lt;BR /&gt;  echo "ERROR: $BDFMEGS does not exist!"&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;SUM=0&lt;BR /&gt;&lt;BR /&gt;# Cut out the first line from output&lt;BR /&gt;$BDFMEGS | sed '1,1d' | grep -v : | while read a b c d e f&lt;BR /&gt;do&lt;BR /&gt;  SUM=`expr $SUM + $c`&lt;BR /&gt;  #echo $SUM&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "Total Space Used (MB) = $SUM"&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Sep 2006 11:11:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003928#M98464</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2006-09-18T11:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003929#M98465</link>
      <description>You had {tot=+$1} where you meant to have {tot+=$1} .&lt;BR /&gt;Awk was very non-judgemental and just did what it was told. :-)</description>
      <pubDate>Mon, 18 Sep 2006 11:24:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003929#M98465</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2006-09-18T11:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003930#M98466</link>
      <description>Or simply use the long form instead of the compact one to avoid confusion i.e.&lt;BR /&gt;&lt;BR /&gt;cat mydf.out |awk 'BEGIN {tot=0} {tot=tot+$1} END {print tot}'</description>
      <pubDate>Mon, 18 Sep 2006 13:09:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003930#M98466</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-09-18T13:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003931#M98467</link>
      <description>just switch your =+ to += and your fine, however you might be awarded the useless use of cat award. ;p&lt;BR /&gt;&lt;BR /&gt;awk '{tot+=$1}END{print tot}' mydf.out</description>
      <pubDate>Mon, 18 Sep 2006 13:20:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003931#M98467</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-09-18T13:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003932#M98468</link>
      <description>Thanks very much guys, much appreciated.&lt;BR /&gt;&lt;BR /&gt;10 out of 10 for me for the useles cat award!!&lt;BR /&gt;&lt;BR /&gt;It's a bad habit I am trying to break.&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Tue, 19 Sep 2006 02:09:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003932#M98468</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-09-19T02:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: using awk to calculate</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003933#M98469</link>
      <description>;-)</description>
      <pubDate>Tue, 19 Sep 2006 02:10:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-awk-to-calculate/m-p/5003933#M98469</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-09-19T02:10:44Z</dc:date>
    </item>
  </channel>
</rss>

