<?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 to perl (sum on columns) in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5151999#M50280</link>
    <description>Hi Den:&lt;BR /&gt;&lt;BR /&gt;One way:&lt;BR /&gt;&lt;BR /&gt;perl -nale 'next if $.&amp;lt;2;$count1+=$F[1];$count2+=$F[2];END{print "### $count1 $count2"}' file&lt;BR /&gt;&lt;BR /&gt;Remember, 'awk' numbers fields starting with one (1).  Perl is more mathematical and starts at zero (0).  The '-a' means "auto-split" into an array '@F'.  The '-n' gives us a read loop for the file(2) specified as an argument.  The '-l' adds a linefeed to each output line and the '-e' signals the script follows.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 22 Jan 2009 16:27:01 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-01-22T16:27:01Z</dc:date>
    <item>
      <title>awk to perl (sum on columns)</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5151998#M50279</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I wrote this small awk script. Objective is to sum columns... &lt;BR /&gt;&lt;BR /&gt;echo $(cat $OUTPUT_FILE | awk 'NR &amp;gt; 0 {&lt;BR /&gt; countN1 += $2&lt;BR /&gt; countN2 += $3&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;END {&lt;BR /&gt;  print "### countN1 countN2 "&lt;BR /&gt;}') &amp;gt;&amp;gt; $OUTPUT_FILE&lt;BR /&gt;&lt;BR /&gt;How to do the same things but with perl ?&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 22 Jan 2009 15:47:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5151998#M50279</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-01-22T15:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: awk to perl (sum on columns)</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5151999#M50280</link>
      <description>Hi Den:&lt;BR /&gt;&lt;BR /&gt;One way:&lt;BR /&gt;&lt;BR /&gt;perl -nale 'next if $.&amp;lt;2;$count1+=$F[1];$count2+=$F[2];END{print "### $count1 $count2"}' file&lt;BR /&gt;&lt;BR /&gt;Remember, 'awk' numbers fields starting with one (1).  Perl is more mathematical and starts at zero (0).  The '-a' means "auto-split" into an array '@F'.  The '-n' gives us a read loop for the file(2) specified as an argument.  The '-l' adds a linefeed to each output line and the '-e' signals the script follows.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 22 Jan 2009 16:27:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5151999#M50280</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-22T16:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: awk to perl (sum on columns)</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5152000#M50281</link>
      <description>Thanks again James! Perfect !&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 22 Jan 2009 16:34:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-perl-sum-on-columns/m-p/5152000#M50281</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-01-22T16:34:11Z</dc:date>
    </item>
  </channel>
</rss>

