Last active
February 8, 2017 08:15
-
-
Save jatinkrmalik/4875e654e8fac80ec7458608bfcd5dc2 to your computer and use it in GitHub Desktop.
A small script to implement countdown in bash
This file contains 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
#!/bin/bash | |
# A small script to implement countdown in bash | |
seconds=200; # Set countdown time in seconds | |
date1=$((`date +%s` + $seconds)); # to get future time in seconds | |
# for asthetics | |
echo "" | |
# when present time is greater than or equal to the future time | |
while [ "$date1" -ge `date +%s` ]; | |
do | |
# print the difference in time with -ne flag for input in same line | |
echo -ne "Tick tock $(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment