If you are using Ubuntu, this command will print out the information to help you to compute the speed.
cat /proc/net/dev
A sample output of the above command line is something like this:
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 1094736293 1076693 0 0 0 0 0 0 1094736293 1076693 0 0 0 0 0 0
eno1: 132120552758 616841563 0 0 0 0 0 1323233 376143801828 548682127 0 0 0 0 0 0
wlp2s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
From there, you can use grep
, or awk
, or cut
, or regular expression to filter only the interface that you want to see (i.e. the wireless interface).
For example, if your wireless interface is eno1, using this command line will print out the current receive/transmit Kbytes per second:
awk '{i++; recv[i]=$1; trans[i]=$2}; END{print (recv[2]-recv[1])/1000 "KBps " (trans[2]-trans[1])/1000 " KBps"}' <(cat /proc/net/dev | grep eno1 | awk -F' ' '{print $2 " " $10}'; sleep 1; cat /proc/net/dev | grep eno1 | awk -F' ' '{print $2 " " $10}')