I have a bash script that runs iperf and outputs the average bandwdith ie 3.80 Mbits/sec. What i'd like to do is get this output as an average of the connection speed.
So if I have a 10Mbit connection i'd like to know what 3.80 Mbits/sec is of that so output something like
3.80 Mbits/sec 38%
I'm not sure how to do this.
My script does
iperf -c 1.1.1.1 >> /tmp/iperf.log
echo -e " \t $(awk '/Bandwidth/ {getline}; END{print $7, $8}' $iperflog"
which returns
3.80 Mbits/sec
i'd like it to return
3.80 Mbits/sec 38%
Here an example with
awk
:To apply to your script just add the
awk
part after your command: