if [ "$(ping -c 1 google.com | grep "0%")" != "" ] then INTERNET=true else INTERNET=false fi while [ "$INTERNET" == "true" ] do echo "we have internet" done