owagh owagh - 5 months ago 46
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?

let DIFF=(`date +%s -d 20120203`-`date +%s -d 20120115`)/86400
echo $DIFF