Skip to content

Instantly share code, notes, and snippets.

@emorisse
Created September 21, 2016 13:52
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 emorisse/12445359977876a5c731a75c76bde7e1 to your computer and use it in GitHub Desktop.
Save emorisse/12445359977876a5c731a75c76bde7e1 to your computer and use it in GitHub Desktop.
# Source: http://serverfault.com/a/532600
Floor ()
{
DIVIDEND=${1};
DIVISOR=${2};
RESULT=$(( ( ${DIVIDEND} - ( ${DIVIDEND} % ${DIVISOR}) )/${DIVISOR} ));
echo ${RESULT}
}
Timecount ()
{
s=${1};
HOUR=$( Floor ${s} 60/60 );
s=$((${s}-(60*60*${HOUR})));
MIN=$( Floor ${s} 60 );
SEC=$((${s}-60*${MIN}));
while [ $HOUR -ge 0 ]; do
while [ $MIN -ge 0 ]; do
while [ $SEC -ge 0 ]; do
printf "%02d:%02d:%02d\033[0K\r" $HOUR $MIN $SEC;
SEC=$((SEC-1));
sleep 1;
done;
SEC=59;
MIN=$((MIN-1));
done;
MIN=59;
HOUR=$((HOUR-1));
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment