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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting files older than 7 days shezam Shell Programming and Scripting 4 07-09-2008 05:40 AM
delete file older than N days ericaworld Shell Programming and Scripting 7 02-21-2008 08:34 AM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 05:40 AM
How can I delete files older than 7 days? odogbolu98 UNIX for Dummies Questions & Answers 3 02-26-2002 08:35 PM
delete files older than 7 days lesstjm UNIX for Dummies Questions & Answers 1 11-06-2001 10:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-28-2007
krishnarao krishnarao is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
List directory 7 days older

Say folder archive/ contains many folder each created on a day. this folder may contain files. i want to write a script to delete all the folder inside archive/ which are 7 days older. i used the below script for the reason.

find archive -mtime +7 -type d -exec rm -r {} \;

pls suggest me if the above command is correct or any other way to handle this.
  #2 (permalink)  
Old 06-28-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Your command is fine -- it should work without problems.
  #3 (permalink)  
Old 06-28-2007
krishnarao krishnarao is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
Thanks for the suggestion.
  #4 (permalink)  
Old 06-28-2007
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,342
Add a slash in front of the directory name:


Code:
find /archive -mtime +7 -type d -exec rm -r {} \;

Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0