加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 用行号ping

发布时间:2020-05-30 02:35:44 所属栏目:Linux 来源:互联网
导读:简单的问题:如何在 Linux上进行ping操作以显示输出中的行号? 我的意思是: 1 64 bytes from www.site.com (2.7.1.1): icmp_req=1 ttl=247 time=17.9 ms2 64 bytes from www.site.com (2.7.1.1): icmp_req=2 ttl=247 time=16.1 ms3 64 bytes fro

简单的问题:如何在 Linux上进行ping操作以显示输出中的行号?

我的意思是:

1 64 bytes from www.site.com (2.7.1.1): icmp_req=1 ttl=247 time=17.9 ms
2 64 bytes from www.site.com (2.7.1.1): icmp_req=2 ttl=247 time=16.1 ms
3 64 bytes from www.site.com (2.7.1.1): icmp_req=3 ttl=247 time=16.1 ms

解决方法

nl命令将行号添加到其输入,因此您可以将ping的输出传递给nl.
% ping -c3 google.com | nl
     1  PING google.com (74.125.224.105) 56(84) bytes of data.
     2  64 bytes from nuq04s08-in-f9.1e100.net (74.125.224.105): icmp_req=1 ttl=55 time=31.2 ms
     3  64 bytes from nuq04s08-in-f9.1e100.net (74.125.224.105): icmp_req=2 ttl=55 time=14.8 ms
     4  64 bytes from nuq04s08-in-f9.1e100.net (74.125.224.105): icmp_req=3 ttl=55 time=16.3 ms

     5  --- google.com ping statistics ---
     6  3 packets transmitted,3 received,0% packet loss,time 2002ms
     7  rtt min/avg/max/mdev = 14.851/20.833/31.286/7.417 ms

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读