Pergunta

Is there a way to customize the display of the 'ping' command?

It's a bit superfluous, but I'd like to customize it to be 1) easier to read and 2) require less screen real estate.

Current ping:

64 bytes from 69.169.182.80: icmp_seq=31 ttl=61 time=9.168 ms
64 bytes from 69.169.182.80: icmp_seq=32 ttl=61 time=0.967 ms

Goal:

31 from 69.169.182.80: 9.168 ms
32 from 69.169.182.80: 0.967 ms

Or an even simpler version:

31: 9.168 ms
32: 0.967 ms
Foi útil?

Solução

You can try using awk:

ping 69.169.182.80 | awk '{ gsub("time=", "") ; gsub("icmp_seq=",""); print $5": " $7 " "$8 }'

Then You can place this line in Your ~/.bash_profile file:

function pingq { ping $1 | awk '{ gsub("time=", "") ; gsub("icmp_seq=",""); print $5": " $7 " "$8 }'; };

And later use it like:

pingq 69.169.182.80

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top