nload is handy when it comes to live monitoring of bandwidth consumption. It displays an ongoing process window and you can look at it. While this is useful for humans, it isn't useful for scripts.

I'd like to get currrent download or upload for particular network interface as a string and be done with it immediately.

Something like this: nload devices en3, but without the ongoing process. is this possible?

  • must be nload ?
    – pLumo
    May 6 '19 at 9:42
  • no, not at all.
    – sanjihan
    May 6 '19 at 9:55

ifstat prints the incoming and outoming traffic in an easy list to parse:

ifstat [-i device] [delay] [count]

You might need to install it, provided from most package systems, e.g. apt-get install ifstat or yum install ifstat or similar depending on your system.

Output is like this:

$ ifstat -i en3
 KB/s in  KB/s out
    0.25      0.00
    0.72      1.06
    0.45      0.07

To parse it, you can use e.g. awk:

$ ifstat -i en3 1s 1 | awk 'NR==3 {print $1}'

Upload would be $2.

By default, the unit is Kilobytes/s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.