[RndTbl] Roundtable Digest, Vol 153, Issue 6

Michael Doob Michael.Doob at umanitoba.ca
Thu Sep 21 13:45:49 CDT 2017


On the other hand awk has

1. a variable NR the contains the current line number
2. a % operator that can be used to compute modulo 7
3. a getline command that reads the next line of input

That's all you need.

Cheers,
Michael

------------------------------------------------------------------
Michael Doob                    Telephone: (204) 474-9796
Department of Mathematics       email: Michael.Doob at UManitoba.ca
University of Manitoba
Winnipeg, MB, Canada R3T 2N2
------------------------------------------------------------------

________________________________________
From: Roundtable <roundtable-bounces at muug.ca> on behalf of roundtable-request at muug.ca <roundtable-request at muug.ca>
Sent: September 21, 2017 1:23:52 PM
To: roundtable at muug.ca
Subject: Roundtable Digest, Vol 153, Issue 6

Send Roundtable mailing list submissions to
        roundtable at muug.ca

To subscribe or unsubscribe via the World Wide Web, visit
        https://muug.ca/mailman/listinfo/roundtable
or, via email, send a message with subject or body 'help' to
        roundtable-request at muug.ca

You can reach the person managing the list at
        roundtable-owner at muug.ca

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Roundtable digest..."


Today's Topics:

   1. Looking for some AWK magic (Wyatt Zacharias)
   2. Re: Looking for some AWK magic (Sean Cody)
   3. Re: Looking for some AWK magic (John Lange)


----------------------------------------------------------------------

Message: 1
Date: Thu, 21 Sep 2017 12:01:33 -0500
From: Wyatt Zacharias <wyatt at magitech.ca>
To: Continuation of Round Table discussion <roundtable at muug.ca>
Subject: [RndTbl] Looking for some AWK magic
Message-ID:
        <CANd2pR2wwERFj2R6_JswyzT91cpnq+RM7KhgC1goP6CEbbJoiQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

So I've got a storage appliance that I'm trying to generate a growth chart
on, but the output format of the statistics is not in a usable format.

The output looks like this, with each day of the week in a column, and then
6 rows of data underneath, and then it repeats.
   -2-      -3-      -4-      -5-      -6-       -7-       -8-
5827.1   6865.6   3551.2   4649.5   4006.6   15803.5   10305.0
 199.4    353.4    175.9    200.7    172.5     584.0     554.2
  9.9x     4.4x     6.4x     5.9x     6.3x      5.6x      5.3x
  3.0x     4.4x     3.2x     3.9x     3.7x      4.9x      3.5x
 29.2x    19.4x    20.2x    23.2x    23.2x     27.1x     18.6x
  96.6     94.9     95.0     95.7     95.7      96.3      94.6

  -23-     -24-     -25-     -26-     -27-      -28-      -29-
2798.2   2235.3   2357.9   4701.3   9074.3   13796.5   11705.7
  86.7     74.1    131.6    178.1    449.3     483.5     473.7
 11.4x    12.0x     7.0x     8.1x     3.9x      6.3x      6.7x
  2.8x     2.5x     2.6x     3.2x     5.2x      4.6x      3.7x
 32.3x    30.2x    17.9x    26.4x    20.2x     28.5x     24.7x
  96.9     96.7     94.4     96.2     95.0      96.5      96.0

  -30-     -31-      -1-      -2-      -3-       -4-       -5-
2798.6   2274.5   2325.8   2472.1   2526.0   13955.3   11224.2
  86.7     88.9    145.2    115.2    105.6     497.9     432.4
 10.8x    10.1x     7.4x     8.1x     9.8x      6.2x      6.9x
  3.0x     2.5x     2.2x     2.7x     2.4x      4.5x      3.8x
 32.3x    25.6x    16.0x    21.5x    23.9x     28.0x     26.0x
  96.9     96.1     93.8     95.3     95.8      96.4      96.1

Is there a way I can get awk to process 6 rows of each column at a time?


--
Wyatt Zacharias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://muug.ca/pipermail/roundtable/attachments/20170921/f6deacc9/attachment-0001.html>

------------------------------

Message: 2
Date: Thu, 21 Sep 2017 12:22:48 -0500
From: Sean Cody <sean at tinfoilhat.ca>
To: Continuation of Round Table discussion <roundtable at muug.ca>
Subject: Re: [RndTbl] Looking for some AWK magic
Message-ID: <7cb73bec4e8c83f27e5a2fff09293100 at tinfoilhat.ca>
Content-Type: text/plain; charset=US-ASCII; format=flowed

On 2017-09-21 12:01, Wyatt Zacharias wrote:
> So I've got a storage appliance that I'm trying to generate a growth
> chart on, but the output format of the statistics is not in a usable
> format.
>
> The output looks like this, with each day of the week in a column, and
> then 6 rows of data underneath, and then it repeats.
>
>    -2-      -3-      -4-      -5-      -6-       -7-       -8-
> 5827.1   6865.6   3551.2   4649.5   4006.6   15803.5   10305.0
>  199.4    353.4    175.9    200.7    172.5     584.0     554.2
>   9.9x     4.4x     6.4x     5.9x     6.3x      5.6x      5.3x
>   3.0x     4.4x     3.2x     3.9x     3.7x      4.9x      3.5x
>  29.2x    19.4x    20.2x    23.2x    23.2x     27.1x     18.6x
>   96.6     94.9     95.0     95.7     95.7      96.3      94.6
>
>   -23-     -24-     -25-     -26-     -27-      -28-      -29-
> 2798.2   2235.3   2357.9   4701.3   9074.3   13796.5   11705.7
>   86.7     74.1    131.6    178.1    449.3     483.5     473.7
>  11.4x    12.0x     7.0x     8.1x     3.9x      6.3x      6.7x
>   2.8x     2.5x     2.6x     3.2x     5.2x      4.6x      3.7x
>  32.3x    30.2x    17.9x    26.4x    20.2x     28.5x     24.7x
>   96.9     96.7     94.4     96.2     95.0      96.5      96.0
>
>   -30-     -31-      -1-      -2-      -3-       -4-       -5-
> 2798.6   2274.5   2325.8   2472.1   2526.0   13955.3   11224.2
>   86.7     88.9    145.2    115.2    105.6     497.9     432.4
>  10.8x    10.1x     7.4x     8.1x     9.8x      6.2x      6.9x
>   3.0x     2.5x     2.2x     2.7x     2.4x      4.5x      3.8x
>  32.3x    25.6x    16.0x    21.5x    23.9x     28.0x     26.0x
>   96.9     96.1     93.8     95.3     95.8      96.4      96.1
>
> Is there a way I can get awk to process 6 rows of each column at a
> time?
>

Not particularly... awk is a single line filter, doing multi-line leads
to madness.
But you can use the line number to gauge/tract state.

Crappy awk pseudo code...

BEGIN {state counter = 0 }
^- { Line starts with ^- it's a header line, set state counter to 0. }
^[0-9]+ & state counter == 0 { next line starts with a number and state
counter is 0 so do first line thing, increment state counter }
^[0-9]+ & state counter == 1 { next line starts with a number and state
counter is 1 so do second line thing, increment state counter }
...
^[0-9]+ & state counter == 5 { next line starts with a number and state
counter is 5 so last line in the sequence, set counter to 0. }
repeat
END { output your fancy stats }

You can then use a data structure like an array or a 2d matrix to handle
the data you output at the end.

(PS. Yes I know you can nest the stanzas but trying to keep the
suggestion clear)

--
Sean


------------------------------

Message: 3
Date: Thu, 21 Sep 2017 13:23:45 -0500
From: John Lange <john at johnlange.ca>
To: Continuation of Round Table discussion <roundtable at muug.ca>
Subject: Re: [RndTbl] Looking for some AWK magic
Message-ID:
        <CAPfXosh9TEbDN=urXpPjcythrNFUO8TEE-p5y2EmLTGcT2=tvQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I apologize that this isn't a real answer since you asked specifically
about awk; but typically if I'm faced with anything beyond a simple filter,
I generally resort to something with a bit more complex processing ability,
like perl, or even php. They work great from the command line and it's sooo
much easier to process complex data sets. You can even output the results
directly into a database or anything else you want.

Downside? There really isn't one. Sure, in theory they are slightly
"heaver" to invoke than awk, but if you are having to resort to multiple
layers of pipes or any other bash trickery, it might actually be more
efficient to use perl/php or similar.

John


On Thu, Sep 21, 2017 at 12:22 PM, Sean Cody <sean at tinfoilhat.ca> wrote:

> On 2017-09-21 12:01, Wyatt Zacharias wrote:
>
>> So I've got a storage appliance that I'm trying to generate a growth
>> chart on, but the output format of the statistics is not in a usable
>> format.
>>
>> The output looks like this, with each day of the week in a column, and
>> then 6 rows of data underneath, and then it repeats.
>>
>>    -2-      -3-      -4-      -5-      -6-       -7-       -8-
>> 5827.1   6865.6   3551.2   4649.5   4006.6   15803.5   10305.0
>>  199.4    353.4    175.9    200.7    172.5     584.0     554.2
>>   9.9x     4.4x     6.4x     5.9x     6.3x      5.6x      5.3x
>>   3.0x     4.4x     3.2x     3.9x     3.7x      4.9x      3.5x
>>  29.2x    19.4x    20.2x    23.2x    23.2x     27.1x     18.6x
>>   96.6     94.9     95.0     95.7     95.7      96.3      94.6
>>
>>   -23-     -24-     -25-     -26-     -27-      -28-      -29-
>> 2798.2   2235.3   2357.9   4701.3   9074.3   13796.5   11705.7
>>   86.7     74.1    131.6    178.1    449.3     483.5     473.7
>>  11.4x    12.0x     7.0x     8.1x     3.9x      6.3x      6.7x
>>   2.8x     2.5x     2.6x     3.2x     5.2x      4.6x      3.7x
>>  32.3x    30.2x    17.9x    26.4x    20.2x     28.5x     24.7x
>>   96.9     96.7     94.4     96.2     95.0      96.5      96.0
>>
>>   -30-     -31-      -1-      -2-      -3-       -4-       -5-
>> 2798.6   2274.5   2325.8   2472.1   2526.0   13955.3   11224.2
>>   86.7     88.9    145.2    115.2    105.6     497.9     432.4
>>  10.8x    10.1x     7.4x     8.1x     9.8x      6.2x      6.9x
>>   3.0x     2.5x     2.2x     2.7x     2.4x      4.5x      3.8x
>>  32.3x    25.6x    16.0x    21.5x    23.9x     28.0x     26.0x
>>   96.9     96.1     93.8     95.3     95.8      96.4      96.1
>>
>> Is there a way I can get awk to process 6 rows of each column at a
>> time?
>>
>>
> Not particularly... awk is a single line filter, doing multi-line leads to
> madness.
> But you can use the line number to gauge/tract state.
>
> Crappy awk pseudo code...
>
> BEGIN {state counter = 0 }
> ^- { Line starts with ^- it's a header line, set state counter to 0. }
> ^[0-9]+ & state counter == 0 { next line starts with a number and state
> counter is 0 so do first line thing, increment state counter }
> ^[0-9]+ & state counter == 1 { next line starts with a number and state
> counter is 1 so do second line thing, increment state counter }
> ...
> ^[0-9]+ & state counter == 5 { next line starts with a number and state
> counter is 5 so last line in the sequence, set counter to 0. }
> repeat
> END { output your fancy stats }
>
> You can then use a data structure like an array or a 2d matrix to handle
> the data you output at the end.
>
> (PS. Yes I know you can nest the stanzas but trying to keep the suggestion
> clear)
>
> --
> Sean
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.ca
> https://muug.ca/mailman/listinfo/roundtable
>



--
John Lange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://muug.ca/pipermail/roundtable/attachments/20170921/cb118f73/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Roundtable mailing list
Roundtable at muug.ca
https://muug.ca/mailman/listinfo/roundtable


------------------------------

End of Roundtable Digest, Vol 153, Issue 6
******************************************



More information about the Roundtable mailing list