Friday, February 10, 2012

Shell script - snippets

Loop through dates

startdate=`/bin/date --date="2007-07-01" +%Y-%m-%d`
enddate=`/bin/date --date="2011-07-01" +%Y-%m-%d`

foldate="$startdate"
until [ "$foldate" == "$enddate" ]
do
echo $foldate
foldate=`/bin/date --date="$foldate 1 month" +%Y-%m-%d`
done

No comments:

Post a Comment