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 04:08:57 +0000

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]