0

I want to get the return of the bash script speedtest-cli (it is used to check the speed of the internet), my system is CentOS.

This is the return of ./speedtest-cli:

[root@192 ~]# ./speedtest-cli
Retrieving speedtest.net configuration...
Testing from Oi Velox (179.198.68.183)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Station Net Provedor (Duque de Caxias) [10.54 km]: 37.818 ms
Testing download speed................................................................................
Download: 50.2 Mbit/s
Testing upload speed................................................................................................
Upload: 12.69 Mbit/s

I want a bash script that gets this part of the return "Download: 50.2 Mbit/s" and save it in a variable, how can I do this?

PS: This is my CentOS 6.9 Server located in Rio de Janeiro, Brazil.

Gabriel Caprini
  • 13
  • 1
  • 1
  • 4
  • one simple way could be to redirect the output of the script in some text file and saving the `string` to a variable: ./speedtest-cli > some_text_file; download=`grep "Download" some_text_file`; echo $download – User123 Jun 16 '18 at 19:37
  • `download=$(grep 'Download' file)` or `download=$(awk '/Download/' file)` – Cyrus Jun 16 '18 at 19:54
  • Thanks a billion guys! I got it! :D I'm new to this... – Gabriel Caprini Jun 16 '18 at 23:29

0 Answers0