diff options
author | David Wührer <def@raspberrypi> | 2019-10-13 13:25:14 +0200 |
---|---|---|
committer | David Wührer <def@raspberrypi> | 2019-10-13 13:25:14 +0200 |
commit | e60829f7b9c61dc870173a8dd8f2f85c17517ec4 (patch) | |
tree | e99f252f307b3a4e31df5ff45cf5daf6bccaf9f6 /countdown |
Initial commit
Diffstat (limited to 'countdown')
-rwxr-xr-x | countdown | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/countdown b/countdown new file mode 100755 index 0000000..59daf56 --- /dev/null +++ b/countdown @@ -0,0 +1,23 @@ +#!/bin/bash + +declare -i t=$1 + +while [ $((t--)) -ne 0 ]; do + if [ $t -gt 5400 ]; then + h=$((t/3600)) + m=$(((t-(h*3600))/60)) + if [ $m -lt 10 ]; then m=0$m; fi + s=$((t%60)) + if [ $s -lt 10 ]; then s=0$s; fi + echo -en "\r$h:$m:$s " + elif [ $t -gt 90 ]; then + m=$((t/60)) + s=$((t%60)) + if [ $s -lt 10 ]; then s=0$s; fi + echo -en "\r$m:$s " + else + echo -en "\r$t " + fi + sleep 1 +done +echo -en "\r" |