2011/07/08

shell script tips: date command

"date" command is useful when we write a shell script which does per-day-processing.


#/bin/sh

fromdate="20110101"
todate="20110501"

date=${fromdate}
while [ ${date} -le ${todate} ]
do
# do somewhat you want

date=`date -d "$(date +2011-06-30) +1 day" +%Y%m%d`
done

No comments:

Post a Comment

100