Countdown Clock

MIN=1 && for i in $(seq $(($MIN*60)) -1 1); do echo -n "$i, "; sleep 1; done; echo -e "\n\nBOOOM! Time to start."
Simple countdown clock that should be quite portable across any Bourne-compatible shell. I used to teach for a living, and I would run this code when it was time for a break. Usually, I would set "MIN" to 15 for a 15-minute break. The computer would be connected to a projector, so this would be projected on screen, front and center, for all to see.
Sample Output
60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 

BOOOM! Time to start.

12
By: atoponce
2010-06-20 15:19:12

4 Alternatives + Submit Alt

  • Countdown clock - Counts down from $MIN minutes to zero. I let the date command do the maths. This version doesn't use seq. Show Sample Output


    11
    MIN=10;for ((i=MIN*60;i>=0;i--));do echo -ne "\r$(date -d"0+$i sec" +%H:%M:%S)";sleep 1;done
    flatcap · 2011-02-20 11:56:28 7
  • The biggest advantage over atoponce's nifty original is not killing the scrollback. Written assuming bash, but shouldn't be terribly difficult to port to other shells. S should be multiple spaces, but I can't get commandlinefu to save/show them properly, any help?


    1
    function countdown { case "$1" in -s) shift;; *) set $(($1 * 60));; esac; local S=" "; for i in $(seq "$1" -1 1); do echo -ne "$S\r $i\r"; sleep 1; done; echo -e "$S\rBOOM!"; }
    kniht · 2010-06-30 12:20:01 1

  • 0
    MIN=10 && for i in $(seq $(($MIN*60)) -1 1); do printf "\r%02d:%02d:%02d" $((i/3600)) $(( (i/60)%60)) $((i%60)); sleep 1; done
    bugmenot · 2011-02-20 10:24:22 0
  • I find the other timers are inaccurate. It takes some microseconds to perform the date function. Therefore, using date/time math to calculate the time for us results in millisecond accuracy. This is tailored to the BusyBox date function. May need to change things around for GNU date function. Show Sample Output


    -1
    let T=$(date +%s)+3*60;while [ $(date +%s) -le $T ]; do let i=$T-$(date +%s); echo -ne "\r$(date -d"0:0:$i" +%H:%M:%S)"; sleep 0.3; done
    davidk · 2019-10-22 15:04:21 5

What Others Think

Like many commands that use seq, they won't work on Mac OSX. You can replace $(seq $(($MIN*60)) -1 1) with something like $(jot - $(($MIN*60)) 1) for the same result.
vgm64 · 558 weeks and 1 day ago
yeah like this one: http://www.commandlinefu.com/commands/view/7938/countdown-clock
tcfusion · 523 weeks and 3 days ago
Command line fu is that website who works on all latest article which are grossing first. It has many new articles that are coming on site. You can get professional assignment help uk to solve your task easily. Sign up and get your notifications on for more.
JosephHyett · 57 weeks and 2 days ago
Thank you for the information to share that would be pretty wise and helping to complete my thesis. As I’m a history student and I was looking for the update of border algorithm. Thumbs up with your wise sharing on https://www.topbritishwriters.com/ukassignmentshelp-review/ and continue with your excellent work always.
MichaelA · 38 weeks and 6 days ago
Thank you for provide us such an knowledgeable post. Keep it up! Caroline, Personal statement writer. http://www.personalstatementfolks.co.uk/medicine-personal-statement/">http://www.personalstatementfolks.co.uk/medicine-personal-statement/
CarolineWebb · 34 weeks and 3 days ago
Thank you for provide us such an knowledgeable post. Keep it up! Caroline, Personal statement writer. http://www.personalstatementfolks.co.uk/medicine-personal-statement/
CarolineWebb · 34 weeks and 3 days ago
Doing IoT assignments is trying and dangerous considering the way that a lot of explicit words are open in it. Once visit homepage for further details. Regardless, I by and large do with noteworthy eagerness since it interests me the most.
Ahmed74 · 9 weeks and 5 days ago
Jen Coyne has beginning late done the best in this thirty-minute program named as "Validness Matters". Check this home for more ideas. This program has exhibited me the best tips related with the prosperity.
Ahmed74 · 9 weeks and 5 days ago
My decision of joining Meditation Teacher Training has given me a colossal store of focal points. Try this homepage for more info. This accessibility has made a couple of wonderful traits in me.
Ahmed74 · 9 weeks and 5 days ago
Massachusetts, officially the Commonwealth of Massachusetts, is the most populous state in the New England region of the northeastern United States. While MaxRemind top rank medical billing company of USA offers it's Medical Billing Services Massachusetts , we also offer medical credentialing services in Massachusetts.
stevematt · 6 weeks ago
It has wound up being clearly not difficult to plan getting is this specific and current world. I hope you will like this http://www.colonchecker.com/how-to-correct-my-essay-properly/">correct my essay online free source. The online technique for course is redesiging its design on the planet as it is the best strategy for getting moved bearing. There are limitless educational records open on web.
Ahmed74 · 5 weeks ago
There are various stages on the web that are looking for online educators to fill in as partners, course modelers, inspirations or speakers. Visit correct my essay online free for getting more ideas. You can do this as demonstrated by your own time span and win extra cash.
anonymous00 · 5 weeks ago
As per my perspective, this is in excess of a making base. I often visit http://www.grammarcheckonline.net/spelling-and-grammar-check-online/ to read a fine article. Take a gander at all the assurance designs and how fittingly every one of them have been put.
anonymous00 · 5 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: