The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: purging a set of files
2greazy
Newbie
Rank: 1



UID 31
Digest Posts 0
Credits 0
Posts 28
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:48 AM  Profile | P.M. 
purging a set of files



purging a set of files



hi frineds,
i want to delete a set of files which are older than 7 days from teh current date.i am totally enw to shell scripting, can anyone help me with a sample code to list out the files which are older and then remove them from the directory.


please help
thanks


Top
DaveyBoy
Newbie
Rank: 1



UID 107
Digest Posts 0
Credits 0
Posts 30
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:48 AM  Profile | P.M. 
code:

find /path/to/files -type f  -mtime +7 -exec rm -f {} \;

to be sure you are getting what you think, run this first to check:


code:

find /path/to/files -type f  -mtime +7 -exec ls -l  {} \;
Top
cosmokramer
Newbie
Rank: 1



UID 97
Digest Posts 0
Credits 0
Posts 37
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:48 AM  Profile | P.M. 
see if this works for you:

code:
Top
 

 

All times are GMT, the time now is Mar 18, 2010 10:38 PM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.004989 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP