REQ-1:
Suppose I have the following files
XX_20070202000101.zip
XX_20080223000101.zip
XX_20080226000101.zip
XX_20080227000101.zip
XX_20080228000101.zip
XX_20080229000101.zip
Suppose sysdate [today's date] = 29 Feb 2007
I need to delete all files older than 3 days from current sysdate
After my archival process,
i.e I will retain the files
XX_20080227000101.zip
XX_20080228000101.zip
XX_20080229000101.zip
AND DELETE The fololowing files
XX_20070202000101.zip
XX_20080223000101.zip
XX_20080226000101.zip
In my case , I need to compare the sysdate against the timestamp value which is avaialble in the file name [XX_YYYYMMDDHHMMSS.zip].
# suppose today is 20080229 (date + %Y%m%d)
# then to get two days before you can write
yesterday1=`TZ=$TZ+24 date +%Y%m%d`
yesterday2=`TZ=$TZ+48 date +%Y%m%d`
# Then yesterday1 = 20080228 yesterday2 = 20080227