Bash command for comparing two dates
Hi all,
Is there a command in Bash that allows one to compare the current date grabbed from the network with another one specified in a script file? I cannot use cron since the hardware in question will not be running constantly and anacron from what I can see doesn't parse dates at all; merely intervals which isn't sufficient in this case. Any ideas; suggestions for workarounds? thanks, cc. |
Yes, the 'date' command is what you want.
Here are some examples: http://unix.stackexchange.com/questi...te-differences you can search for more. It depends on what exactly you want to calculate. |
Quote:
|
It wasn't that easy to find. You're lucking I was looking for exactly the same thing just yesterday for a script I was making.
|
http://www.linuxquestions.org/questi...es-4175454050/
short version: Code:
echo $((($(date +%s -d "June 5, 2013")-$(date +%s -d "June 5, 1960"))/86400)) days. |
Quote:
in "man bash" and "man date" to be specific. |
See: that thread.
|
All times are GMT -5. The time now is 07:00 PM. |