I have file contains results of my speed test that has run in past few hours through my script. The results in the text file is follows, Script started on Monday 23 July 2018 04:41:11 PM IST file name is speedtest.txt Script started on Monday 23 July 2018 04:41:11 PM IST
root@xxxx: root@xxxx:~#
root@xxxx: root@xxxx:~# speedtest-cli --simple
Ping: 40.629 ms
Download: 19.67 Mbit/s
Upload: 1.08 Mbit/s
root@xxxx: root@xxxx:~# speedtest-cli --simple
Ping: 51.229 ms
Download: 22.16 Mbit/s
Upload: 0.80 Mbit/s
root@xxxx: root@xxxx:~# speedtest-cli --simple
Ping: 50.924 ms
Download: 21.82 Mbit/s
Upload: 1.07 Mbit/s
root@xxxx: root@xxxx:~# speedtest-cli --simple
Ping: 51.438 ms
Download: 20.87 Mbit/s
Upload: 0.67 Mbit/s
root@xxxx: root@xxxx:~# speedtest-cli --simple
Ping: 51.149 ms
Download: 21.51 Mbit/s
Upload: 0.94 Mbit/s
root@xxxx: root@xxxx:~# exit
exit
Script done on Monday 23 July 2018 04:51:11 PM IST
I am taking the Download speed alone with the following awk command,
sudo cat speedtest.txt | grep "Download:" | cut -d ' ' -f2 | awk '{ SUM += $1} END { print SUM }' | awk '{ SUM = $1/5} END {print SUM}'
Out put of the above command is,
21.206
Now I want to verify the above value is greater than my assured value or not.
I tried to save this value in a separate runTime variable and compare it with my static value let say 21.206 >= 25 or not. But I could no find the command working for me. It keep adding a new line after it stored in the new variable. So is there any way that I can compare the output value with awk and can show it is true or false? I am using expect script to save the file "speedtest.txt