Skip to content

Instantly share code, notes, and snippets.

@rahji
Last active August 4, 2020 20:21
Show Gist options
  • Save rahji/7ecd48a04ee2250bef6c8b5bf29bfd38 to your computer and use it in GitHub Desktop.
Save rahji/7ecd48a04ee2250bef6c8b5bf29bfd38 to your computer and use it in GitHub Desktop.
#!/bin/bash
# countdown timer, for use with OBS Studio or the like
# writes a mm:ss countdown to a file every second
# Usage: ./countdown.sh SECS FILENAME
### CAUTION: there is no error checking at all
### and FILENAME WILL GET CLOBBERED!
# if you are using MacOS, you will need to install gdate
# using homebrew: brew install coreutils
# if on Windows, you'll want to install Ubuntu on Windows
# using: https://ubuntu.com/tutorials/ubuntu-on-windows
for i in $(seq $1 0) ; do
# if [ "$i" -gt 59 ] ; then
gdate -d@$i -u +%M:%S > $2
# else
# gdate -d@$i -u +%S
# fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment