如何获得网络传输量?

interlc 2009-09-09 02:06:03
在Linux下用 ifconfig命令会得到如下内容:
eth0 Link encap:Ethernet HWaddr
inet addr:210.45.251.33 Bcast:210.45.251.255 Mask:255.255.255.0
inet6 addr: fe80::215:58ff:fe47:3fa1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:120220 errors:0 dropped:0 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13062030 (12.4 MiB) TX bytes:7125 (6.9 KiB)
Interrupt:20
如果我只想得到RX bytes:13062030 (12.4 MiB) TX bytes:7125 (6.9 KiB))
中的12.4和6.9,应该怎么做?
...全文
70 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
interlc 2009-09-10
  • 打赏
  • 举报
回复
不用再等了,高手就是高手,不得不佩服
naiveC 2009-09-09
  • 打赏
  • 举报
回复
steptodream真是Shell高手啊。
steptodream 2009-09-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 steptodream 的回复:]
/sbin/ifconfig | grep -i "RX bytes:" | awk '{print substr($3,2,length($3)-1) " " substr($7,2,length($7)-1)}'
[/Quote]
2个数字会以空格分隔显示
steptodream 2009-09-09
  • 打赏
  • 举报
回复
/sbin/ifconfig | grep -i "RX bytes:" | awk '{print substr($3,2,length($3)-1) " " substr($7,2,length($7)-1)}'

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧