Skip to content

Instantly share code, notes, and snippets.

@jatinkrmalik
Last active Feb 8, 2017
Embed
What would you like to do?
A small script to implement countdown in bash
#!/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