Last active
August 29, 2015 14:08
-
-
Save r1beast02/d9fadcf1f880a66ac142 to your computer and use it in GitHub Desktop.
NYE
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 | |
# retrieve difference seconds for new years day and today's date from epoch | |
nye=$( date -d "Jan 1 2015" +%s) | |
today=$( date +"%s") | |
# get difference in seconds between 2 moments and convert to days/hours/minutes/seconds | |
seconds=$(($nye - $today)) | |
days=$(($seconds / 86400)) | |
seconds=$(($seconds % 86400)) | |
hours=$(($seconds / 3600)) | |
seconds=$(($seconds % 3600)) | |
minutes=$(($seconds / 60)) | |
seconds=$(($seconds % 60)) | |
echo "$days day(s) $hours hour(s) $minutes minute(s) $seconds second(s) until New Year's"! |
dope! you have seconds declared a lot I was wondering if you used % for a reason?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍