Last active
December 27, 2024 06:58
-
-
Save krohne/298c6393cf3dd6063b054dd297ba7714 to your computer and use it in GitHub Desktop.
Countdown timer in bash shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $1 = # of seconds | |
# $@ = What to print after "Waiting n seconds" | |
countdown() { | |
secs=$1 | |
shift | |
msg=$@ | |
while [ $secs -gt 0 ] | |
do | |
printf "\r\033[KWaiting %.d seconds $msg" $((secs--)) | |
sleep 1 | |
done | |
echo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: