Created
December 8, 2022 05:14
-
-
Save San3-Cod3/dfc039cb2bb2da0a3a6852a71be76027 to your computer and use it in GitHub Desktop.
speedtest-cli — results you care about, returned ~ all on a single line; w/o the faff.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# create/place in: /home/YOU/ or /usr/bin/ # ( sudo needed for latter ) # | |
# chmod +x speedtest-cli_jq_json.sh # | |
# sudo apt-get install -y jq speedtest-cli # | |
# ˇ jq explained simply @ link below ˇ # | |
# https://puu.sh/JslQO/c0d473928e.png # | |
# ˇ usage: ˇ # | |
# ./speedtest-cli_jq_json.sh # ( if in: /home/YOU/ ) # | |
# speedtest-cli_jq_json.sh # ( if placed in: /usr/bin/ ) # | |
# ˇ how snippet looks once executed ˇ # | |
# https://puu.sh/JslST/397941d6ca.png # | |
read p d u < <(\ | |
speedtest-cli --json \ | |
| jq -r '[.ping, .download/1000000, .upload/1000000] | join(" ")' | |
) | |
printf 'Ping: %.02f ms || Download: %.02f Mbit/s || Upload: %.02f Mbit/s\n' "$p" "$d" "$u" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create an alias for this, e.g. st
This makes it quick and easy to use; you can make the alias permanent too
Add speedtest-cli_jq_json.sh as an alias in: /home/User.You/.bash_aliases -- if missing then create: .bash_aliases --
touch .bash_aliasses
---- and then add inside .bash_aliases, the following line:
alias st='/home/User.You/speedtest-cli_jq_json.sh'
Save it, and then afterwards do this:
source ~/.bash_aliases
Then, to start speedtest-cli_jq_json.sh, from anywhere, just type:
st
and press Enter. But making sure to use your own username above...If you want to forgo the alias part, you can still start speedtest-cli_jq_json.sh from the directory its in by doing this: ./speedtest-cli_jq_json.sh
You might possibly need to make speedtest-cli_jq_json.sh executable, so to do that, type:
chmod +x speedtest-cli_jq_json.sh