Skip to content

Instantly share code, notes, and snippets.

@dphov
Created December 24, 2017 15:26
Show Gist options
  • Select an option

  • Save dphov/21b5fc7bbc16e9532a97c9790aad00d4 to your computer and use it in GitHub Desktop.

Select an option

Save dphov/21b5fc7bbc16e9532a97c9790aad00d4 to your computer and use it in GitHub Desktop.

Revisions

  1. dphov created this gist Dec 24, 2017.
    14 changes: 14 additions & 0 deletions countdown.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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
    )