I have data from ‘speedtest-cli’ that get gathered in a cronjob.
12818 "Ridge Wireless" "Cupertino, CA" 2024-08-17T17:15:02.811911Z 142.96369289624104 33.358 322418432.2265161 23600938.32538198 67.160.240.135
18531 Wave "San Francisco, CA" 2024-08-17T18:15:01.957127Z 83.30302174397045 28.576 514447518.90742075 24265080.17742009 67.160.240.135
18531 Wave "San Francisco, CA" 2024-08-17T19:15:02.006891Z 83.30302174397045 33.523 498012209.6915029 23804897.964512113 67.160.240.135
18531 Wave "San Francisco, CA" 2024-08-17T20:15:02.800014Z 83.30302174397045 28.459 411379941.90105027 23681434.10062648 67.160.240.135
32408 "EGI Hosting" "Santa Clara, CA" 2024-08-17T21:15:02.543215Z 143.01655083159983 28.8 446156606.22138727 23902144.606594093 67.160.240.135
32408 "EGI Hosting" "Santa Clara, CA" 2024-08-17T22:15:04.113615Z 143.01655083159983 27.703 344460192.3618878 23487079.94843895 67.160.240.135
32408 "EGI Hosting" "Santa Clara, CA" 2024-08-17T23:15:02.831512Z 143.01655083159983 28.307 478754656.0807323 23643468.646293264 67.160.240.135
12818 "Ridge Wireless" "Cupertino, CA" 2024-08-18T00:15:03.190852Z 142.96369289624104 30.545 284195879.4387585 18459056.85763892 67.160.240.135
12818 "Ridge Wireless" "Cupertino, CA" 2024-08-18T01:15:01.977997Z 142.96369289624104 31.603 352557160.9015237 24035464.022335984 67.160.240.135
12818 "Ridge Wireless" "Cupertino, CA" 2024-08-18T02:15:02.302942Z 142.96369289624104 30.178 411204274.5646509 23825237.50161968 67.160.240.135
Note the use of quotation. The rule is that if a token is a multi word string it is enclosed in quotes. Let’s make the assumption that zero, one ore more tokens could fall under that rule. Download speed is column 7, upload speed is column 8.
Trying to get the average of the last 10 measurements using awk gives undesired result.
tail -10 speed.dat | awk '{sum+=$7;n++} END {print sum/n;}'
689.376
Obviously awk fails to treat quotation properly.
What’s the easiest solution? Teach awk handling of the quotation? Or use other program to do the job? (within usual linux install)