I have just started learning shell script recently, so I don\'t know much about it.
I am trying to find example of time based while loop but not having any luck.
For a more modern approach...
declare -ir MAX_SECONDS=5 declare -ir TIMEOUT=$SECONDS+$MAX_SECONDS while (( $SECONDS < $TIMEOUT )); do # foo done
typeset -ir MAX_SECONDS=5 typeset -ir TIMEOUT=$SECONDS+$MAX_SECONDS while (( $SECONDS < $TIMEOUT )); do # bar done