Thanx to some help from Tink, I am now able to rename files using the date (format /data/openldaptemp/dump-yyyymmdd.ldif). However, I want to delete files older than seven days old
based on the date stored in the file name. I don't want to use the date attributes of the files for a variety of reasons. Thus, this does NOT work for me -
find -name "dump*" -ctime +7 -exec rm {} \;
What I tried to do was something along these lines -
lookback=8
while [ -e /data/openldaptemp/dump-$(date --date='${lookback} days ago' +%Y%m%d).ldif ]
do
rm /data/openldaptemp/dump-$(date --date='${lookback} days ago' +%Y%m%d).ldif
lookback=$lookback+1
done
However, the date command doesn't allow variables (or I can't figure out how to get it to allow variables) in the --date='' option. How should I do this?
Colin