Skip to content

Instantly share code, notes, and snippets.

@aont
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save aont/62cc8e541b54cfa9ae84 to your computer and use it in GitHub Desktop.

Select an option

Save aont/62cc8e541b54cfa9ae84 to your computer and use it in GitHub Desktop.
timer
#!/bin/sh
TIME_BEGIN=$(date +%s)
TIME_NOW="$TIME_BEGIN"
TIME_END=$(date -d "$1" +%s)
TIME_LEFT=$(expr "$TIME_END" - "$TIME_NOW")
while [ ${TIME_LEFT} -gt 0 ]
do
echo ${TIME_LEFT}s left
sleep 1
TIME_NOW=$(date +%s)
TIME_LEFT=$(expr ${TIME_END} - ${TIME_NOW})
done
while :
do
echo "Time is up!" \\a
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment