<?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: Doing Sum of Colums with awk in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906402#M96765</link>
    <description>Hi Hein,Peter,&lt;BR /&gt;&lt;BR /&gt;I installed gwak on the HPUX and that did the trick. So far 100% done. Thanks Peter.&lt;BR /&gt;&lt;BR /&gt;Hein,&lt;BR /&gt;One last and final question:&lt;BR /&gt;I need to include the digit before Data ID i.e.&lt;BR /&gt;06-11-2600:45"1" 7 198 &lt;BR /&gt;{ if (NR &amp;gt; 1) {&lt;BR /&gt;     line = $0&lt;BR /&gt;     len  = length($0)&lt;BR /&gt;     pos  = 14       # Changed from 15 to 14&lt;BR /&gt;     adder = 10      # first size is exclusive of type/size&lt;BR /&gt;     while (len - pos &amp;gt; 10) {&lt;BR /&gt;       $0 = substr (line,pos+1,20)&lt;BR /&gt;       etc......&lt;BR /&gt;reason being :&lt;BR /&gt;DATA_Quality&lt;BR /&gt;=============&lt;BR /&gt;0 DEFAULT default value&lt;BR /&gt;1 SECURE data of this integration interval are secure&lt;BR /&gt;2 TIME CORR during this cycle the system time was changed by the MML command&lt;BR /&gt;3 NO INIT counter could not become initialized&lt;BR /&gt;If the value (DATA_Q) is " 0 || 1 " then continue adding or else skip line (dont take into consideration (No adding is necessary).&lt;BR /&gt;&lt;BR /&gt;I must admit Hein, your idea is brilliant, great stuff. I could learn a lot from you.&lt;BR /&gt;&lt;BR /&gt;Thanks Again&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 04 Dec 2006 14:46:15 GMT</pubDate>
    <dc:creator>Chris Frangandonis</dc:creator>
    <dc:date>2006-12-04T14:46:15Z</dc:date>
    <item>
      <title>Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906386#M96749</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am stuck with trying to calc certain columns with awk. What I am trying to achieve is the following :&lt;BR /&gt;&lt;BR /&gt;First row&lt;BR /&gt;=========&lt;BR /&gt;If column 2 is 7 (Data ID = 7) the next yte will e the length of the field (198). Thereafter &lt;BR /&gt;the columns start (9 yte length). Following 6 ytes will e 6 (Data ID = 6), following that will &lt;BR /&gt;e the next length (1656) with its columns.&lt;BR /&gt;&lt;BR /&gt;Second row&lt;BR /&gt;===========&lt;BR /&gt;Column 2 is 0 (Data Id= 0) and the next yte is the length 198 (do nothing as there are no columns). &lt;BR /&gt;Following that, 6 ytes will e 1 (Data ID = 1) and the next 6 ytes is the length (282). &lt;BR /&gt;Thereafter are the columns until the length (282), max 19 columns. The following 6 ytes is 5&lt;BR /&gt;(Data ID ==5) and following yte are length (270), max columns 25 &lt;BR /&gt;&lt;BR /&gt;Third row&lt;BR /&gt;==========&lt;BR /&gt;Column 2 is 7 (Data ID =7) and next yte is the length 198 Now add what was in the First row in coloum1&lt;BR /&gt;to column 1 in the third row (358316+ 280236) and so on for all other columns. When we get to Data ID= 6 do the same&lt;BR /&gt;add all columns from row 1 ( Data ID = 6) to third row where Data Id = 6 of column 1 and so on&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Example File&lt;BR /&gt;See Attachment&lt;BR /&gt;&lt;BR /&gt;In other words try and add all the Data ID's columns&lt;BR /&gt;06-11-2600:151 7 198 358316 20172 116524 200888 2124 16585 117573 189039 8310 0 20 0 92 24 48 2932 2664 0 3692 0 3172&lt;BR /&gt;06-11-2600:301 7 198 280236 15376 112812 131512 2144 12743 131538 102357 1122 0 100 0 32 28 8 3792 3420 0 3196 32 2576&lt;BR /&gt;06-11-2600:451 7 198 295100 12696 113328 146524 3412 8619 115907 114759 1493 0 280 0 8 0 32 3696 3260 0 2764 0 2300&lt;BR /&gt;Sum Data ID 7 933652 48244 342664 sum sum .......&lt;BR /&gt;&lt;BR /&gt;Output&lt;BR /&gt;&lt;BR /&gt;Data ID = 7 933652 48244 342664 $4 $5 $6 $7 $8 etc.................................&lt;BR /&gt;Data ID = 6 0 0 0 284 0 0 0 27000 .....&lt;BR /&gt;Data ID = 0 (No Columns)&lt;BR /&gt;Data ID = 1 0 0 0 0 0 0 0 0 0 71 0 &lt;BR /&gt;Data ID = 5 0 518 0 0 0 etc&lt;BR /&gt;&lt;BR /&gt;Hope this is clear enough&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 01 Dec 2006 02:12:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906386#M96749</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-01T02:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906387#M96750</link>
      <description>&lt;!--!*#--&gt;Here is a solution using the awk auto-split to fields.&lt;BR /&gt;I only tried this on windows, where awk seems to be limited to 100 fields, which is not enough for your need. So you may have to use 'substr' to select a chunk from the input line and split that. (Save line, assing chunk to $0, use $1.. $NF, next chunk) &lt;BR /&gt;I'll leave that part of the exercise for you :-)&lt;BR /&gt;I left the debuf print statements in there.&lt;BR /&gt;I assume the length is always the same for each data-id, or at least the last one counts (sic).&lt;BR /&gt;&lt;BR /&gt;Enjoy!&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;-------------- test.awk ---------&lt;BR /&gt;&lt;BR /&gt;{ if (NF &amp;gt; 4) {&lt;BR /&gt;     print "nf=", NF;  &lt;BR /&gt;     i = 2;&lt;BR /&gt;     while (i &amp;lt; NF) {&lt;BR /&gt;       type = $i++;&lt;BR /&gt;       if (type &amp;gt; max) { max = type};&lt;BR /&gt;       size = $i++;&lt;BR /&gt;       val  = $i;&lt;BR /&gt;       print "type = ", type, "size = ", size, "value = ", val;&lt;BR /&gt;       fields[type] = size / 9;&lt;BR /&gt;       for (j=1; j &amp;lt; fields[type]; j++) {&lt;BR /&gt;          a[type,j] += $i++;&lt;BR /&gt;          if (i &amp;gt; NF) { j = 999 };&lt;BR /&gt;          }&lt;BR /&gt;       }&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;    for (i=0; i&amp;lt;=max; i++) {&lt;BR /&gt;        printf ("\nDATA ID = %d", i);&lt;BR /&gt;        for (j=1; j&lt;FIELDS&gt;&lt;/FIELDS&gt;            printf (" %d", a[i,j]);&lt;BR /&gt;         }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;----------------------------------&lt;BR /&gt;C:\Temp&amp;gt;awk test.awk test.txt&lt;BR /&gt;nf= 100&lt;BR /&gt;type =  7 size =  198 value =  358316&lt;BR /&gt;type =  6 size =  1656 value =  0&lt;BR /&gt;nf= 51&lt;BR /&gt;type =  0 size =  198 value =  1&lt;BR /&gt;type =  5 size =  270 value =  0&lt;BR /&gt;nf= 100&lt;BR /&gt;type =  7 size =  198 value =  280236&lt;BR /&gt;type =  6 size =  1656 value =  0&lt;BR /&gt;nf= 51&lt;BR /&gt;type =  0 size =  198 value =  1&lt;BR /&gt;type =  5 size =  270 value =  0&lt;BR /&gt;nf= 100&lt;BR /&gt;type =  7 size =  198 value =  295100&lt;BR /&gt;type =  6 size =  1656 value =  0&lt;BR /&gt;nf= 51&lt;BR /&gt;type =  0 size =  198 value =  1&lt;BR /&gt;type =  5 size =  270 value =  0&lt;BR /&gt;&lt;BR /&gt;DATA ID = 0 3 846 0 0 0 0 0 0 0 0 0 71 0 0 0 0 0 0 0 0 0&lt;BR /&gt;DATA ID = 1&lt;BR /&gt;DATA ID = 2&lt;BR /&gt;DATA ID = 3&lt;BR /&gt;DATA ID = 4&lt;BR /&gt;DATA ID = 5 0 518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;BR /&gt;DATA ID = 6 0 0 0 284 0 0 0 27000 0 0 0 0 0 13139 9468 36802 265 1569 30758 71 203 924 4793 64 0 5747 0 109 0 17 0 0 0 0 1 0 0 0 0 1&lt;BR /&gt; 0 0 27 0 11 2 15 0 0 0 0 0 0 0 26 0 4 2 10 0 0 0 0 0 0 0 7 0 0 5712 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;BR /&gt; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;BR /&gt; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;BR /&gt;DATA ID = 7 933652 48244 342664 478924 7680 37947 365018 406155 10925 0 400 0 132 52 88 10420 9344 0 9652 32 8048&lt;BR /&gt;C:\Temp&amp;gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2006 04:43:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906387#M96750</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-01T04:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906388#M96751</link>
      <description>Chris,&lt;BR /&gt;awk has a limit of 199 fields per record, you may have to work with gawk !</description>
      <pubDate>Fri, 01 Dec 2006 04:48:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906388#M96751</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-12-01T04:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906389#M96752</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;Many Thanks. I think you understood what I was getting at. I dont understand your statment (Save line, assing chunk to $0, use $1.. $NF, next chunk)? Could you please explain .&lt;BR /&gt;Would it be possible to do the following  for eg when 7 use the 198 (length) as substr($3,0,length($3)) and the same for 6  1656 and 0 198 etc !!!!!&lt;BR /&gt;&lt;BR /&gt;Thanks Agian&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2006 06:26:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906389#M96752</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-01T06:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906390#M96753</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;Why would I help you further when you reward the first effort with a slap in the face: '0 points' !&lt;BR /&gt;&lt;BR /&gt;Let's assume that was an accident.&lt;BR /&gt;&lt;BR /&gt;Here is an example using the re-assignment to $0, causing awk to re-evaluate the split.&lt;BR /&gt;&lt;BR /&gt;It 'almost' works. There is some inconsistency in the data, or a tweak needed in the offest calculation.&lt;BR /&gt;Basically the data format stinks. It is almost fixed column, but not exactly.&lt;BR /&gt;&lt;BR /&gt;Check this out. &lt;BR /&gt;(my time is up for this exercise)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;{ if (NR &amp;gt; 1) {&lt;BR /&gt;     $0 = substr ($0, 15); # skip first column&lt;BR /&gt;     print "nf=", NF;  &lt;BR /&gt;     while (NF &amp;gt; 1) {&lt;BR /&gt;       type = $1;&lt;BR /&gt;       if (type &amp;gt; max) { max = type};&lt;BR /&gt;       size = $2;&lt;BR /&gt;print "*" substr ($0,1,20) "* type = ", type, "size = ", size ;&lt;BR /&gt;       fields[type] = size / 9;&lt;BR /&gt;       if (size &amp;gt; 882) { fields[type] = 97 }&lt;BR /&gt;       for (j=3; j &amp;lt; fields[type] + 2 ; j++) {&lt;BR /&gt;          a[type,j] += $j;&lt;BR /&gt;          }&lt;BR /&gt;       $0 = substr ($0, index($0,$2) + length($2) + size);&lt;BR /&gt;       }&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;    for (i=0; i&amp;lt;=max; i++) {&lt;BR /&gt;        printf ("\nDATA ID = %d", i);&lt;BR /&gt;        for (j=3; j&lt;FIELDS&gt;&lt;/FIELDS&gt;            printf (" %d", a[i,j]);&lt;BR /&gt;         }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2006 11:10:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906390#M96753</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-01T11:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906391#M96754</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;I dont not realise that I allocated "0" pionts to you. I did initially give 7 points , but seems like my mouce's rolled over to "0". Can we rectify this and how &lt;BR /&gt;My Apologise once again&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 01 Dec 2006 11:12:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906391#M96754</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-01T11:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906392#M96755</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;I don't not realize that I allocated "0" points to you. I did initially give 7 points , but seems like my mouce's rolled over to "0". Can we rectify this and how &lt;BR /&gt;My Apologize once again&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 01 Dec 2006 11:12:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906392#M96755</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-01T11:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906393#M96756</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot. 90% there, some small questions. If it is possible with you, that is to spend a bit more time to continue with this. The reason for this is that I have a couple of questions which could help&lt;BR /&gt;1) I get the following error "cannot have more than 199 fields" , I was thinking to FS=" " and then substr. I have only awk installed on the servers and not nawk or gawk.&lt;BR /&gt;2) With field one i.e. Data ID = 7 = 9 bytes but for the others it is 6 byte length Data ID = 5,6,61,62,1&lt;BR /&gt;&lt;BR /&gt;Thanks Again&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 01 Dec 2006 11:43:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906393#M96756</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-01T11:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906394#M96757</link>
      <description>&lt;!--!*#--&gt;A little closer, but not exactly there.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; 1) I get the following error "cannot have more than 199 fields" , I was thinking to FS=" " and then substr. I have only awk installed on the servers and not nawk or gawk.&lt;BR /&gt;&lt;BR /&gt;Yeah, you pretty much have to give up on the automatic field seperators, and just go by position. Except... that the positions are not entirely predictable in the provided data.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; 2) With field one i.e. Data ID = 7 = 9 bytes but for the others it is 6 byte length Data ID = 5,6,61,62,1&lt;BR /&gt;&lt;BR /&gt;That was NOT clear from the question, but it was clear from the data... now that you mention it. Using the $x fields hides the length.&lt;BR /&gt;&lt;BR /&gt;It also seems the the size for the first series does not include the type + size fields themselve, but for subsequent series they do !?!&lt;BR /&gt;&lt;BR /&gt;Here is a rewrite using offsets and a lot of fudges and adders to try to make it fit.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;---------------------------------&lt;BR /&gt;{ if (NR &amp;gt; 1) {&lt;BR /&gt;     line = $0&lt;BR /&gt;     len  = length($0)&lt;BR /&gt;print "== " NR " : " len&lt;BR /&gt;     pos  = 15       # skip first column  &lt;BR /&gt;     adder = 10      # first size is exclusive of type/size&lt;BR /&gt;     while (len - pos &amp;gt; 10) {&lt;BR /&gt;       $0 = substr (line,pos,20)&lt;BR /&gt;       fudge = index($0,$2) + length($2)&lt;BR /&gt;       type = $1&lt;BR /&gt;       size = $2&lt;BR /&gt;       seen[type] = 1&lt;BR /&gt;      &lt;BR /&gt;print "*" $0 "* type = ", type, "size = ", size &lt;BR /&gt;       width = (type == 7) ? 9 : 6&lt;BR /&gt;       fields[type] = int((size - fudge) / width)&lt;BR /&gt;       for (j=0; j &amp;lt; fields[type]; j++) {&lt;BR /&gt;          a[type,j] += substr(line, pos + fudge + j*width, width)&lt;BR /&gt;          }&lt;BR /&gt;       pos = pos + size + adder + fudge - 10&lt;BR /&gt;       adder = 0  # after first time just add size&lt;BR /&gt;       }&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;    for (i in seen) {&lt;BR /&gt;        printf ("\nDATA ID=%d, Fields=%d : ", i, fields[i] )&lt;BR /&gt;        for (j=0; j&lt;FIELDS&gt;&lt;/FIELDS&gt;            printf (" %d", a[i,j])&lt;BR /&gt;         }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;C:\Temp&amp;gt;awk -f test.awk tmp.txt | more&lt;BR /&gt;== 2 : 1878&lt;BR /&gt;*     7 198   358316 * type =  7 size =  198&lt;BR /&gt;*    6  1656     0   * type =  6 size =  1656&lt;BR /&gt;== 3 : 774&lt;BR /&gt;*     0 198          * type =  0 size =  198&lt;BR /&gt;*    1   282     0   * type =  1 size =  282&lt;BR /&gt;*  5   270     0   22* type =  5 size =  270&lt;BR /&gt;== 4 : 1878&lt;BR /&gt;*     7 198   280236 * type =  7 size =  198&lt;BR /&gt;*    6  1656     0   * type =  6 size =  1656&lt;BR /&gt;== 5 : 777&lt;BR /&gt;*     0 198          * type =  0 size =  198&lt;BR /&gt;*     1    282     0 * type =  1 size =  282&lt;BR /&gt;*   5   270     0   1* type =  5 size =  270&lt;BR /&gt;== 6 : 1878&lt;BR /&gt;*     7 198   295100 * type =  7 size =  198&lt;BR /&gt;*    6  1656     0   * type =  6 size =  1656&lt;BR /&gt;== 7 : 775&lt;BR /&gt;*     0 198          * type =  0 size =  198&lt;BR /&gt;*    1   282     0   * type =  1 size =  282&lt;BR /&gt;*   5   270     0   1* type =  5 size =  270&lt;BR /&gt;&lt;BR /&gt;DATA ID=0, Fields=31 :  0 0 0 0 0 0 0 0 0 0 0 0 0 0...&lt;BR /&gt;DATA ID=1, Fields=45 :  0 0 0 0 0 0 0 0 0 71 0 0 0...&lt;BR /&gt;DATA ID=5, Fields=43 :  0 518 0 0 0 0 0 0 0 0 0 0 0...&lt;BR /&gt;DATA ID=6, Fields=274 :  0 0 0 284 0 0 0 27000 0 0...&lt;BR /&gt;0 1 0 0 0 0 1 0 0 27 0 11 2 15 0 0 0 0 0 0 0 26 0 4...&lt;BR /&gt;6 0 0 0 0 0 0 0 0 0 469 0 0 0 0 0 1091 0 0 0 0 10 1...&lt;BR /&gt;0 13944 0 21 261 0 0 8 0 0 0 0 0 13944 0 0 0 0 0 0...&lt;BR /&gt;4 1559 71 0 0 0 0 0 1 6 23 172 5137 4 0 7 65 0 2 10...&lt;BR /&gt; 0 0 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 0 0&lt;BR /&gt;DATA ID=7, Fields=20 :  933652 48244 342664 478924...&lt;BR /&gt;</description>
      <pubDate>Sun, 03 Dec 2006 03:52:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906394#M96757</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-03T03:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906395#M96758</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;Firstly I would like to thank you for time and your assistance with my problem. Your are 99% there but I still get the "cannot have more than 199 fields" I was thinking of zipping the file and attaching it so that you could see that I am not changing any columns. If I reduce the amount of columns for , it works well.&lt;BR /&gt;I am using textpad to read the file and not notepad as notepad is a bit different.&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong.&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2006 03:41:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906395#M96758</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-04T03:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906396#M96759</link>
      <description>&lt;BR /&gt;Hello Chris,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; I still get the "cannot have more than 199 fields"&lt;BR /&gt;&lt;BR /&gt;I don't have access to an HPUX box to try this just now. Is that just a warning and it continues or a hard failure?&lt;BR /&gt;Awk on windows does not fail, just does not give access to fields over $99&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;  I was thinking of zipping the file and attaching it so that you could see that I am not changing any columns.&lt;BR /&gt;&lt;BR /&gt;And that looks much cleaner!&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; I am using textpad to read the file and not notepad as notepad is a bit different.&lt;BR /&gt;&lt;BR /&gt;I'm also using textpad.(and sometimes crimson)&lt;BR /&gt;Since you are loooking at the data using windows, how about processing it on windows!?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; What am I doing wrong.&lt;BR /&gt;&lt;BR /&gt;You are using standard awk which is primitive. You need to learn awk better.. if you are going to use it. You probably should be using perl, the data is 'ugly'. Other than that all is well ! :-).&lt;BR /&gt;&lt;BR /&gt;The main part of the script now uses 'substr' to select fields. It still uses $1 and $2 for free format input. Replace that by substr and then you can call awk with -Fx giving a non-whitespace seperator and it will no longer see all those fields. Up to you to do the column counting!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2006 04:31:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906396#M96759</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-04T04:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906397#M96760</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; I still get the "cannot have more than 199 fields"&lt;BR /&gt;&lt;BR /&gt;Have you forgotten my inital mail ?&lt;BR /&gt;From "man awk" :&lt;BR /&gt;" DIAGNOSTICS&lt;BR /&gt;      awk supports up to 199 fields ($1, $2, ..., $199) per record."&lt;BR /&gt;&lt;BR /&gt;Thats on my HPUX 11.11 box.&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2006 04:45:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906397#M96760</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-12-04T04:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906398#M96761</link>
      <description>Hi Gordon,&lt;BR /&gt;&lt;BR /&gt;Firstly thank you and yes you are right. Question on gawk&lt;BR /&gt;1) Which gawk version and is the site from &lt;A href="http://ftp.gnu.org/gnu/gawk/" target="_blank"&gt;http://ftp.gnu.org/gnu/gawk/&lt;/A&gt;&lt;BR /&gt;2) Can Hein's awk script be accommodated to use gawk? I am not to familiar with gawk&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 04 Dec 2006 07:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906398#M96761</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-04T07:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906399#M96762</link>
      <description>Chris,&lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/gawk-3.1.5/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/gawk-3.1.5/&lt;/A&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;A href="http://mirrors.develooper.com/hpux/" target="_blank"&gt;http://mirrors.develooper.com/hpux/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The script should pretty much run as is, but I am not an awk/gawk expert.&lt;BR /&gt;&lt;BR /&gt;Perhaps one of experts has found a way around the 199 field limit ...?</description>
      <pubDate>Mon, 04 Dec 2006 07:27:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906399#M96762</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-12-04T07:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906400#M96763</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;Are you familiar with gawk and can you script run with gawk.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 04 Dec 2006 07:43:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906400#M96763</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-04T07:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906401#M96764</link>
      <description>Sorry, can not try anything on hpux just now.&lt;BR /&gt;I'm out at a customer site and did not set up my rx2620 for remote access this time.&lt;BR /&gt;The 199 error *might* be coming from the debug statement 'print NF'. If so you are in luck. Just delete that line.&lt;BR /&gt;&lt;BR /&gt;Hein.</description>
      <pubDate>Mon, 04 Dec 2006 11:17:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906401#M96764</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-04T11:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906402#M96765</link>
      <description>Hi Hein,Peter,&lt;BR /&gt;&lt;BR /&gt;I installed gwak on the HPUX and that did the trick. So far 100% done. Thanks Peter.&lt;BR /&gt;&lt;BR /&gt;Hein,&lt;BR /&gt;One last and final question:&lt;BR /&gt;I need to include the digit before Data ID i.e.&lt;BR /&gt;06-11-2600:45"1" 7 198 &lt;BR /&gt;{ if (NR &amp;gt; 1) {&lt;BR /&gt;     line = $0&lt;BR /&gt;     len  = length($0)&lt;BR /&gt;     pos  = 14       # Changed from 15 to 14&lt;BR /&gt;     adder = 10      # first size is exclusive of type/size&lt;BR /&gt;     while (len - pos &amp;gt; 10) {&lt;BR /&gt;       $0 = substr (line,pos+1,20)&lt;BR /&gt;       etc......&lt;BR /&gt;reason being :&lt;BR /&gt;DATA_Quality&lt;BR /&gt;=============&lt;BR /&gt;0 DEFAULT default value&lt;BR /&gt;1 SECURE data of this integration interval are secure&lt;BR /&gt;2 TIME CORR during this cycle the system time was changed by the MML command&lt;BR /&gt;3 NO INIT counter could not become initialized&lt;BR /&gt;If the value (DATA_Q) is " 0 || 1 " then continue adding or else skip line (dont take into consideration (No adding is necessary).&lt;BR /&gt;&lt;BR /&gt;I must admit Hein, your idea is brilliant, great stuff. I could learn a lot from you.&lt;BR /&gt;&lt;BR /&gt;Thanks Again&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2006 14:46:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906402#M96765</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-04T14:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906403#M96766</link>
      <description>You could change that first line to explicitly implement the formula in little steps:&lt;BR /&gt;&lt;BR /&gt;{ q = substr ($0,14,1) &lt;BR /&gt;  if ((NR &amp;gt; 1) and ((q == "1") or (q =="0")) ) {&lt;BR /&gt;:&lt;BR /&gt;&lt;BR /&gt;But I would fix it by using the standard awk regular expression filter technique. Change the first line with the IF to read:&lt;BR /&gt;/^..-..-....:..[01]/ { &lt;BR /&gt;&lt;BR /&gt;and drop a line with "}" before the END section.&lt;BR /&gt;&lt;BR /&gt;This makes the main section conditional on the line starting with (^) that date pattern, the (:), two anythings and a 0 or 1 ([01]).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; I must admit Hein, your idea is brilliant, great stuff. I could learn a lot from you.&lt;BR /&gt;&lt;BR /&gt;Thank you. &lt;BR /&gt;(For mere money I'll come over and teach some tricks and methods! I'm a gun for hire, consulting primarily in software/database/application performance space :-)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein van den Heuvel&lt;BR /&gt;HvdH Performance Consulting</description>
      <pubDate>Mon, 04 Dec 2006 15:46:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906403#M96766</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-04T15:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906404#M96767</link>
      <description>Hein,&lt;BR /&gt;&lt;BR /&gt;Brilliant stuff. I used the search "/..-[[01]/ and it works. Magic. &lt;BR /&gt;One last favor, if I ever need some help which I know I would, will it be possible to mail you my questions. It will be questions once a blue moon (No nagging) and if so please post or mail me your address.&lt;BR /&gt;&lt;BR /&gt;Many Thanks and keep up the good stuff&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 04 Dec 2006 16:17:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906404#M96767</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-12-04T16:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Doing Sum of Colums with awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906405#M96768</link>
      <description>It's in my profile, or google for hein hvdh&lt;BR /&gt;[0 points for this please :-]&lt;BR /&gt;&lt;BR /&gt;Hein.</description>
      <pubDate>Mon, 04 Dec 2006 19:18:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doing-sum-of-colums-with-awk/m-p/3906405#M96768</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-04T19:18:32Z</dc:date>
    </item>
  </channel>
</rss>

