$ ping -c 4 -w 4 google.com &> /dev/null && ping -c 4 -w 4 www.yahoo.com &> /dev/null || echo "no internet connection"
But, but, ... if the ping to google succeeds, and the ping to yahoo fails, it prints "no internet".
$ ping -c 4 -w 4 google.com &> /dev/null || ping -c 4 -w 4 www.yahoo.com &> /dev/null || echo "no internet connection"
Better ? --Jasper Noë