标签:fan nbsp gif style class spl etl closed alt
一、记录
1. 实时监控网卡流量脚本:https://www.kafan.cn/edu/5611612.html awk ‘BEGIN{ OFMT="%.3f"; devf="/proc/net/dev"; while(("cat "devf) | getline) { if($0 ~ /:/ && ($10+0) > 0) { split($1,tarr,":"); net[tarr[1]]=$10+tarr[2]; print tarr[1],$10+tarr[2]; } } close(devf); while((system("sleep 1 ")) >=0) { system("clear"); while( getline < devf ) { if($0 ~ /:/ && ($10+0) > 0) { split($1,tarr,":"); if(tarr[1] in net) { print tarr[1],":",($10+tarr[2]-net[tarr[1]])*8/1024,"kb/s"; net[tarr[1]]=$10+tarr[2]; } } } close(devf); } }‘ 2.获取网卡所有名称: cat /proc/net/dev | awk ‘{i++; if(i>2){print $1}}‘ | sed ‘s/^[\t]*//g‘ | sed ‘s/[:]*$//g‘ 3.awk对变量的用法: #!/bin/bash for((i=1;i<4;i++)) do awk -v var=$i ‘{print $var}‘ test.txt done
标签:fan nbsp gif style class spl etl closed alt
原文地址:https://www.cnblogs.com/gufengchen/p/14864432.html