[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] deleteing old files



> From: "Chris Demain" <cdemain@xxxxxxxxxxx>
>> hi does anyone if there is a way to delete file out of a specified
>> directory if they are older then  a required date

> man find
> 
> here are some interesting options (tip of the iceberg):
> -mmin n
> File's data was last modified n minutes ago.
> 
> -mtime n
> File's data was last modified n*24 hours ago.
> 
> -name pattern
> Base of file name (the path with the leading direc­
> tories removed) matches shell pattern pattern.  The
> metacharacters  (`*', `?', and `[]') do not match a
> `.' at the start of the base  name.   To  ignore  a
> directory  and  the files under it, use -prune; see
> an example in the description of -path.
> 
> -newer file
> File was modified more recently than file.   -newer
> is affected by -follow only if -follow comes before
> -newer on the command line.
> 
> 
> find . -type f --some_options | xargs rm

Comparing various ways of skinning cats: I've used the following:

rm -rdf $(find /path/to/ftp/ -ctime +7)

to clear files older than a week in my incoming FTP directory. The flaw here
is that it refuses to delete directories, even though it supposedly should.
Perhaps I should try your way?

pjm