summaryrefslogtreecommitdiff
path: root/bin/countdown
blob: 59daf56e791ee640623286849d764973aae77314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"