Skip to content

Instantly share code, notes, and snippets.

@Skymetal
Last active July 13, 2016 21:15
Show Gist options
  • Save Skymetal/c9b0063da9404f1280b993e6c4ef20f5 to your computer and use it in GitHub Desktop.
Save Skymetal/c9b0063da9404f1280b993e6c4ef20f5 to your computer and use it in GitHub Desktop.
bash: ping google
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
while :
do
date | tr -d '\n'
VAL=`ping -c 5 www.google.com | tail -1 | awk '{print $4}' | cut -d '/' -f 2`
if [[ -z "${VAL// }" ]]
then
printf " == ${RED}ERR"
sleep 5
else
printf " == ${GREEN}$VAL"
sleep 20
fi
printf "${NC}\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment