Created
September 22, 2013 16:06
-
-
Save taiansu/6661354 to your computer and use it in GitHub Desktop.
count down in shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countdown | |
{ | |
local SECONDS=$1 | |
local START=$(date +%s) | |
local END=$((START + SECONDS)) | |
local CUR=$START | |
while [[ $CUR -lt $END ]] | |
do | |
CUR=$(date +%s) | |
LEFT=$((END-CUR)) | |
printf "\r%01d" \ | |
$((LEFT%60)) | |
sleep 1 | |
done | |
echo " " | |
} | |
countdown '5' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment