Skip to content

Instantly share code, notes, and snippets.

@vushe
Forked from krohne/countdown.sh
Created September 20, 2018 17:10
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 vushe/a43f3cdd052e4ab29a575b0f6c25190a to your computer and use it in GitHub Desktop.
Save vushe/a43f3cdd052e4ab29a575b0f6c25190a to your computer and use it in GitHub Desktop.
Countdown timer in bash shell script
#!/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