I want a shell script to delete files in a backup directory.

The files in the directory are named according to dates. For example raw_backup071208:061727 (%y%m%d:%H%M%S). I want to compare the dates and make sure that the file is one week old before i delete it.

Thanks

John

Hey There,

You should be able to do this just by using "find"'s -mtime option

find /directory/ -mtime +7 -exec rm {} \;

That will check all the files in /directory/

Hope that helps :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.