bash网速查看工具

 while :; do a=`ifconfig eth0 | grep bytes | grep TX | awk '{print $5}'`; sleep 1; b=`ifconfig eth0 | grep bytes | grep TX | awk '{print $5}'`;clear ;  echo `echo "scale=3; ( $b - $a )  / 1024 / 1024 " | bc` M/s ; done

脚本家写法

#!/bin/bash

device=   设备名称

net_type=获取监控类型 TX /接受| RX /发送 

info= 获取数据所在行 如果不是空列使用再次抓取语句

while :

do

    get_data=`ifconfig $device | grep bytes | grep $net_type | awk '{$info}'`

    sleep 1

    get_datas=`ifconfig $device | grep bytes | grep $net_type  | awk '{print $info}'`

    clear

    echo `echo "scale=3; ( $b - $a )  / 1024 / 1024 " | bc` M/s

done

猜你喜欢

转载自blog.csdn.net/gtinlian/article/details/84870787