[RndTbl] Looking for some AWK magic

John Lange john at johnlange.ca
Thu Sep 21 13:23:45 CDT 2017


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-0001.html>


More information about the Roundtable mailing list