Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Simple question: how to make ping on Linux to show line numbers in output?

I mean:

1 64 bytes from ( icmp_req=1 ttl=247 time=17.9 ms
2 64 bytes from ( icmp_req=2 ttl=247 time=16.1 ms
3 64 bytes from ( icmp_req=3 ttl=247 time=16.1 ms
share|improve this question

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

% ping -c3 | nl
     1  PING ( 56(84) bytes of data.
     2  64 bytes from ( icmp_req=1 ttl=55 time=31.2 ms
     3  64 bytes from ( icmp_req=2 ttl=55 time=14.8 ms
     4  64 bytes from ( icmp_req=3 ttl=55 time=16.3 ms

     5  --- 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
share|improve this answer
Wow, cool. Didn't know of nl previously. – EEAA Jul 17 '12 at 6:33
@ErikA Yup, it's even part of POSIX. – mgorven Jul 17 '12 at 6:35
... and after all these years I learn about nl. Apparently it also has other meanings than Dutch TLD. +1 to you, Sir! – Janne Pikkarainen Jul 17 '12 at 6:42
nl, now fancy that .. +1 for a cmd i never knew about – The Unix Janitor Jul 17 '12 at 11:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.