Commits

Jason Ryan committed 300aa6c

Variables, local not global

Comments (0)

Files changed (1)

 #!/bin/bash
+# speed snapshot
 
-RXB=$(</sys/class/net/enp2s0/statistics/rx_bytes)
-TXB=$(</sys/class/net/enp2s0/statistics/tx_bytes)
+interface="enp2s0"
+sys_dir="/sys/class/net/${interface}/statistics"
+
+rxb=$(<${sys_dir}/rx_bytes)
+txb=$(<${sys_dir}/tx_bytes)
 sleep 2 
-RXBN=$(</sys/class/net/enp2s0/statistics/rx_bytes)
-TXBN=$(</sys/class/net/enp2s0/statistics/tx_bytes)
-RXDIF=$(echo $((RXBN - RXB)) )
-TXDIF=$(echo $((TXBN - TXB)) )
+rxbn=$(<${sys_dir}/rx_bytes)
+txbn=$(<${sys_dir}/tx_bytes)
 
-echo -e "\x04$((RXDIF / 1024 / 2))KB \x06$((TXDIF / 1024 / 2))KB\x01"
+rxdif=$(echo $((rxbn - rxb)) )
+txdif=$(echo $((txbn - txb)) )
+
+echo -e "\x04$((rxdif / 1024 / 2))KB \x06$((txdif / 1024 / 2))KB\x01"