Quantcast
Channel: ping: show only results - Unix & Linux Stack Exchange
Browsing all 5 articles
Browse latest View live

Answer by Nishant for ping: show only results

If you just want the status (and not milliseconds etc), you can just if it. This work for my usecase: if ping -q -c 1 192.168.8.8 2>&1 > /dev/null ; then echo "Ok" else echo "Fail" fi

View Article



Answer by RomanPerekhrest for ping: show only results

Another awk variation: ping -qc1 google.com 2>&1 | awk -F'/' 'END{ print (/^rtt/? "OK "$5" ms":"FAIL") }' -F'/' - treat slash / as field separator Example output: OK 47.090 ms

View Article

Answer by bu5hman for ping: show only results

If you are not too concerned about the exact error message then how about ping google.com | grep -Po "time.*"

View Article

Answer by Stephen Kitt for ping: show only results

There’s not much you can do with ping itself, but you can do all the processing in AWK, reducing the number of pipes, processes etc.: ping -qc1 google.com 2>&1 | awk -F/ '/^rtt/ { printf "OK...

View Article

ping: show only results

Is it possible to only show the amount of milliseconds when pinging instead of the whole result page? I want to check if my servers are online, so I want to return "OK xyz ms" or "FAIL". I am...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images