linux ping latency print on screen .sh file

C++
ping -qc1 google.com 2>&1 | awk -F'/' 'END{ print (/^rtt/? "OK "$5" ms":"FAIL") }'
Source

Also in C++: