help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Graphing a list of values


From: hancooper
Subject: Graphing a list of values
Date: Sat, 18 Sep 2021 12:32:55 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, September 18, 2021 10:40 AM, Alex fxmbsw7 Ratchev 
<fxmbsw7@gmail.com> wrote:

> well you have an array of 2 per block
> simply as i did, printf %s\ %s\\n "${arr[@]}" | awk '{ print $2 }' | stats_awk

Am using

printf '%s\n' "${arr[@]}" | awk '{ print $2 }'

which seems to work better

> On Sat, Sep 18, 2021, 12:38 hancooper <hancooper@protonmail.com> wrote:
>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Saturday, September 18, 2021 10:07 AM, Alex fxmbsw7 Ratchev 
>> <fxmbsw7@gmail.com> wrote:
>>
>>> well, congrants..
>>
>> Am still left with the problem of how to pass the second field from each 
>> element in array to the awk code.
>>
>>> On Sat, Sep 18, 2021, 11:54 hancooper <hancooper@protonmail.com> wrote:
>>>
>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>> On Saturday, September 18, 2021 8:08 AM, Alex fxmbsw7 Ratchev 
>>>> <fxmbsw7@gmail.com> wrote:
>>>>
>>>>> well its in two mails
>>>>> however the first one made it of an array content of without more than 
>>>>> one field each block, ..and this one does $2 parsing
>>>>> you just exchange the printf by the command that gives you the data
>>>>>
>>>>> greets
>>>>
>>>> Have come up with a neater version
>>>>
>>>> Awk='BEGIN \
>>>> {
>>>> printf ("width: terminal %d\n", width);
>>>> stars = sprintf ("%200s", "");
>>>> printf ("stars: %s\n", stars);
>>>> gsub (".", "*", stars);
>>>> }
>>>> { printf ("%.*s\n", $1, stars); }'
>>>>
>>>> printf '%s\n' 4 1 0 3.75 17 |
>>>> awk -v width="$( tput cols )" "${Awk}"
>>>>
>>>> I can capture the width of the terminal and pass it into an awk variable, 
>>>> make a long array of characters in awk and print a clipped section.
>>>>
>>>> Also need to add auto-scaling to use the width of the terminal, using the 
>>>> largest the largest vales, and output the graph in an END block.
>>>>
>>>>> On Sat, Sep 18, 2021, 10:01 hancooper <hancooper@protonmail.com> wrote:
>>>>>
>>>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>>>> On Saturday, September 18, 2021 7:55 AM, Alex fxmbsw7 Ratchev 
>>>>>> <fxmbsw7@gmail.com> wrote:
>>>>>>
>>>>>>> i posted awk code that does similiar
>>>>>>> you can extract $2 by a awk '{ print $2 }' before it, and not using 
>>>>>>> ${t[*]} for your data piped as input
>>>>>>>
>>>>>>> just curious, did you recieve a mail post with the awk code ?
>>>>>>
>>>>>> Cannot see your code around, except the parts below
>>>>>>
>>>>>>> let me actually fix up the code for your usage
>>>>>>>
>>>>>>> printf %s\ %s\\n @ 20 + 100 . 50 | awk '{ print $2 }' | gawk -v c=15 -v 
>>>>>>> S=+ '{ m = m < $1 ? $1 : m ; s[NR] = $1 } END { while ( ++i <= NR ) 
>>>>>>> print l( int( s[i] / m * c ) ) } function l( n, t ) { t = sprintf( "%-" 
>>>>>>> n "s", "" ) ; gsub( " ", S , t ) ; return t }'
>>>>>>>
>>>>>>> +++
>>>>>>> +++++++++++++++
>>>>>>> +++++++
>>>>>>>
>>>>>>> On Sat, Sep 18, 2021, 09:49 hancooper <hancooper@protonmail.com> wrote:
>>>>>>>
>>>>>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>>>>>> On Saturday, September 18, 2021 5:46 AM, Alex fxmbsw7 Ratchev 
>>>>>>>> <fxmbsw7@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> i used in the awk post i did the max of seen in data yes
>>>>>>>>
>>>>>>>> Somehow I got to pass the second field of each element in the array. 
>>>>>>>> Perhaps sed can help here.
>>>>>>>>
>>>>>>>>> On Sat, Sep 18, 2021, 07:46 hancooper <hancooper@protonmail.com> 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>>>>>>>> On Saturday, September 18, 2021 5:26 AM, Alex fxmbsw7 Ratchev 
>>>>>>>>>> <fxmbsw7@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> you have a max_mb per maxcols too ?
>>>>>>>>>>>
>>>>>>>>>>> i wanted to give it a try but the max_mb is missing, for scaling 
>>>>>>>>>>> right
>>>>>>>>>>>
>>>>>>>>>>> .. ?
>>>>>>>>>>
>>>>>>>>>> I can set a maximum (7200 is a sensible value), or use the maximum 
>>>>>>>>>> in the array.
>>>>>>>>>>
>>>>>>>>>>> On Sat, Sep 18, 2021, 06:09 hancooper via help-bash@gnu.org wrote:
>>>>>>>>>>>
>>>>>>>>>>> > I have an array composed of the following elements and want to 
>>>>>>>>>>> > generate a
>>>>>>>>>>> > graph of the values, distributed over a number of columns 
>>>>>>>>>>> > (ncols=80)
>>>>>>>>>>> >
>>>>>>>>>>> > + 3665.64686592 MB
>>>>>>>>>>> > + 1261.64520768 MB
>>>>>>>>>>> > + 96.35131584 MB
>>>>>>>>>>> > + 61.17171840 MB
>>>>>>>>>>> > + 99.81615072 MB
>>>>>>>>>>> > + 541.22517696 MB
>>>>>>>>>>> > + 1067.42695488 MB
>>>>>>>>>>> > + 462.11600448 MB
>>>>>>>>>>> > + 970.72017120 MB
>>>>>>>>>>> > + 1539.70699584 MB
>>>>>>>>>>> > + 2207.06856864 MB
>>>>>>>>>>> > + 2522.07166848 MB
>>>>>>>>>>> > + 645.12725472 MB
>>>>>>>>>>> > + 104.71848192 MB
>>>>>>>>>>> > + 70.59747552 MB
>>>>>>>>>>> > + 44.05066848 MB
>>>>>>>>>>> >
>>>>>>>>>>> >
>>>>>>>>>>> > For instance
>>>>>>>>>>> >
>>>>>>>>>>> > + 10 MB
>>>>>>>>>>> > + 50 MB
>>>>>>>>>>> > + 100 MB
>>>>>>>>>>> >
>>>>>>>>>>> >
>>>>>>>>>>> > Here would be the result with `ncols=10`
>>>>>>>>>>> >
>>>>>>>>>>> > *
>>>>>>>>>>> > *****
>>>>>>>>>>> > **********
>>>>>>>>>>> >
>>>>>>>>>>> >
>>>>>>>>>>> > Have started with the following, but have to modify to take 
>>>>>>>>>>> > values from an
>>>>>>>>>>> > array. Using `awk` seems as the better way to do this.
>>>>>>>>>>> >
>>>>>>>>>>> > oaggr=("+ 659.28737472 MB" "+ 316.94840736 MB" "+ 163.69489344 
>>>>>>>>>>> > MB")
>>>>>>>>>>> > awk '{$2=sprintf("%-*s", $2, ""); gsub(" ", "=", $2); \\
>>>>>>>>>>> > printf("%-10s%s\\n", $1, $2)}' file
>>>>>>>>>>> >

reply via email to

[Prev in Thread] Current Thread [Next in Thread]