0

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

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by eggi
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.