mynote/linux/net.sh
2021-03-09 22:00:38 +08:00

26 lines
686 B
Bash
Executable File

#! /bin/sh
#
# net.sh
# Copyright (C) 2019 light <light@light-laptop>
#
# Distributed under terms of the MIT license.
#
#!/bin/sh
LANG=""
while true
do
up_time1=`ifconfig $1 | grep "TX packets" | awk '{print $5}'`
down_time1=`ifconfig $1 | grep "RX packets" | awk '{print $5}'`
sleep 1
clear
up_time2=`ifconfig $1 | grep "TX packets" | awk '{print $5}'`
down_time2=`ifconfig $1 | grep "RX packets" | awk '{print $5}'`
up_time=`expr $up_time2 - $up_time1`
down_time=`expr $down_time2 - $down_time1`
up_time=`expr $up_time / 1024`
down_time=`expr $down_time / 1024`
echo 上传速度: $up_time KB/s
echo 下载速度: $down_time KB/s
done