Am using diff to compare 2 directories(A & B) and as ouput i get a list of files which are found only in directory B ( I used grep & sed to create the list).
Now I want to delete the files which are found only in dir B after 3 days.
Please help me with this.
Maybe you can use first the find so that you get all the files you need that are older than 3 days and do then your diff etc. ie. change the order to sort them out.
thanks for replies, but i think these will not help.
Lets say I make a backup of a file named xyz.txt on 22-JAN-2010.
On 15-FEB-2010 I delete it.
When I do diff on 15-FEB-2010 , it will say xyz.txt exist only in the backup.
If I calculate its age it will be 23 days old.
I calculate age of file using the following script:
myfile=xyz.txt
tnow=`date +%s`
tfile=`date +%s -r $myfile`
agesecs=$(($tnow-$tfile)) #Age of filename in seconds
agedays=$(($agesecs/86400)) #Age in days
I want to delete the file 3 days after , relative to 15-FEB-2010.
Using the above script if i compare age on 15-FEB-2010 it will already be > 3 days