The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-03-2008
ramu_indian ramu_indian is offline
Registered User
 

Join Date: May 2008
Posts: 5
Am able to read the lines of file and cutting the two fields using cut command.
Eg. line archive/subdirectory=30
using cut
cat filename|while read line
paths=$"(echo $line | cut -d"=" -f1)"
days=$"(echo $line | cut -d"=" -f2)"
find $paths -type f -mtimd $days -exec rm {} \;

Heres a logical problem. find command is drilling into subdirectories.
If I have a subdirectory inside archive say archive/subdirectory/innerdir
and the retention period for innerdir is 90 days.
The above procedure is deleting all files of subdirectory as it searches files from innerdir too.
Reason: Because in the first run the a command finds all files that are older by 30 days and deletes them

Let me repeat it again
If the retention period for an inner directory/child directory is more than the parent directory the above process fails to restore the files of child directory.

I hope I have made the point clear. Time for an expert to take a glance
Can any one provide me a good solution/idea?

Thanks.
Reply With Quote