The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
deleting files based on file name and modified time ammu UNIX for Dummies Questions & Answers 1 01-22-2008 08:09 AM
how to retrieve original contents of a modified file (modified using vi) novice100 UNIX for Dummies Questions & Answers 3 05-31-2007 05:50 PM
find files modified in a specific month omer_ome UNIX for Advanced & Expert Users 1 07-02-2006 06:43 AM
find files modified in a specific month omer_ome SUN Solaris 1 07-02-2006 06:38 AM
find files modified in a specific month omer_ome HP-UX 1 07-02-2006 06:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-02-2005
Registered User
 

Join Date: Jul 2005
Posts: 30
Deleting file with last modified for 1 month

Hello...
Any body, how to delete the files where last modified for 1 month, would you give some example.
Sorry, im very newbie in scripting.

Thanks.
Reply With Quote
Forum Sponsor
  #2  
Old 07-02-2005
RishiPahuja's Avatar
Registered User
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
Thumbs up

Assuming you want to delete files last modified prior to 30 days and recrusively in directory $DIR command looks like this


Code:
find $DIR -mtime +30 -exec rm -f {} \;
Reply With Quote
  #3  
Old 07-02-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
find <directory to search from> -type f -mtime +30 -exec rm -f {} \;

Be very sure that the directory contains only files which are not required by the sytem.
Reply With Quote
  #4  
Old 07-02-2005
Registered User
 

Join Date: Aug 2001
Posts: 58
this will delete any file that is 30 days or MORE

not exactly 30 days

so if you have files like 31 40 50 100 or more they will get deleted too

be careful
Reply With Quote
  #5  
Old 07-03-2005
Registered User
 

Join Date: Jul 2005
Posts: 30
Thanks

Thanks all
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0