How to use OS X's terminal to ping an IP using the latency as a stopping condition for a loop?
I guess there might be easier way, but it works for me:

#!/bin/bash

TRESHOLD=10

while $(true); do 

    time=$(ping -c 1 google.com | grep time | cut -d ' ' -f 7 | cut -d '=' -f 2 | cut -d '.' -f 1) 

    if [ $time -lt $TRESHOLD ]; then
        echo "Less than $TRESHOLD ($time), continue"
        sleep 1
    else
        echo "More than $TRESHOLD ($time), stop"
        exit
    fi

done


Outputs:

~ $ ./1.sh
Less than 10 (8), continue
Less than 10 (9), continue
Less than 10 (9), continue
Less than 10 (9), continue
Less than 10 (9), continue
More than 10 (11), stop
~ $