How to – Ping with line numbers

The nl command adds line numbers to its input, so you can pipe the output of ping to nl.

 

Example : ping -c3 kartook.com | nl

 

Ping = Command

C3 = How many packets need to send

kartook.com = which destination you want to ping

| = Pipe ( interconnection between ping and nl   or file descriptors for referring )

nl   = number lines of files

 

Here is my output for 6 packets

 

kartook@kartook:~$ ping -c6 8.8.8.8 | nl
1      PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
2      64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=8.14 ms
3      64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=40.8 ms
4      64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=6.00 ms
5      64 bytes from 8.8.8.8: icmp_req=4 ttl=53 time=12.5 ms
6      64 bytes from 8.8.8.8: icmp_req=5 ttl=53 time=3.71 ms
7      64 bytes from 8.8.8.8: icmp_req=6 ttl=53 time=12.8 ms

8      — 8.8.8.8 ping statistics —
9      6 packets transmitted, 6 received, 0% packet loss, time 5007ms
10      rtt min/avg/max/mdev = 3.717/14.011/40.820/12.428 ms
kartook@kartook:~$

Leave a Reply

Your email address will not be published. Required fields are marked *