Skip to content

Instantly share code, notes, and snippets.

@tripadvisor
Created June 2, 2010 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripadvisor/422968 to your computer and use it in GitHub Desktop.
Save tripadvisor/422968 to your computer and use it in GitHub Desktop.
countdown()
(
IFS=:
set -- $*
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
while [ $secs -gt 0 ]
do
sleep 1 &
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60))
secs=$(( $secs - 1 ))
wait
done
echo
)
countdown "00:05:00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment