owagh owagh - 1 year ago 93
Linux Question

How do I get the difference between two dates under bash

Exactly as the question sounds.
I want to subtract say 20120115 from 20120203 and get 19 as the answer.
What is the best way to implement this in a shell script?

Answer Source
let DIFF=(`date +%s -d 20120203`-`date +%s -d 20120115`)/86400
echo $DIFF
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download