I am trying to use awk to search the output of a script for a specific line. Can someone explain why this doesnt return the output: 16.72?
my bash script:
speed=$(./speedtest-cli)
awk '/Download:/ {print $2}' $speed
speedtest-cli
pi@raspberrypi ~/Desktop/PiControl $ ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Charter Communications (xxxxxx)...
Selecting best server based on latency...
Hosted by Charter Communications (yyyy, zz) [67.01 km]: 44.035 ms
Testing download speed........................................
Download: 16.72 Mbit/s
Testing upload speed..................................................
Upload: 3.45 Mbit/s
Note (included in the comments below) I am trying to avoid one-liners because I plan to print multiple lines from the output.
EDIT:
To clarify my end goal. I am trying to run ./speedtest-cli (I am trying not to change this file). I am trying to take its output (the download speed, the upload speed, and the latency) and pass them as individual parameters to another script that will write them to a database. (This project is purely for personal use.... im not trying to use it in an enterprise environment)
From the speedtest-cli output above I want to do this:
MY GOAL:
./another_script 16.72 3.45 44.035
$speed(un-dbl-quoted) the shell turns the data into one big set of words, without new-lines separating the lines. You would see that if you usedset -vxto debug/trace your shell script. Good luck.