Help in writing a shell script

Reply

Join Date: Feb 2008
Posts: 1
Reputation: John Jack is an unknown quantity at this point 
Solved Threads: 0
John Jack John Jack is offline Offline
Newbie Poster

Help in writing a shell script

 
0
  #1
Feb 14th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Help in writing a shell script

 
0
  #2
Feb 15th, 2008
Hey There,

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

Shell Scripting Syntax (Toggle Plain Text)
  1. find /directory/ -mtime +7 -exec rm {} \;

That will check all the files in /directory/

Hope that helps

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC