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
Command for delete the directories which are older than 7 days sridhar sivakot HP-UX 1 02-15-2008 09:11 AM
Removing files older than 7 days texasoeb UNIX for Dummies Questions & Answers 3 04-20-2007 05:04 PM
Find files older than 5 days and remove tem after listing ypatel6871 UNIX for Dummies Questions & Answers 1 09-05-2005 12:00 PM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 05:40 AM
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 11-13-2006
malaymaru malaymaru is offline
Registered User
  
 

Join Date: May 2005
Posts: 54
Need to remove files older than 30 days except directories

Hi,

I need to remove files (*.trc) which are older than 30 days from one location.

My problem is there I do not want to visit any of the directories at that location. I want to search files at that particular location only (need to skip directorys at that location). maxdepth option is there in LINUX find but its not there in solaris.

How can I do that?

Thanks in advance.

Regards,
Malay Maru
  #2 (permalink)  
Old 11-13-2006
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
Hi,

Try the following:


Code:
find . -name "*.trc"  -mtime +30 -exec rm -rf {} \;

Regards,
Nir
  #3 (permalink)  
Old 11-13-2006
malaymaru malaymaru is offline
Registered User
  
 

Join Date: May 2005
Posts: 54
But it will remove the tracefiles which resides under directoris at that location.

I want to skip this directories.

Malay
  #4 (permalink)  
Old 11-13-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433

Code:
find . \( -type d ! -name . -prune \) -o  -mtime +30 -exec rm -rf {} \;


Jean-Pierre.
  #5 (permalink)  
Old 11-13-2006
er_aparna er_aparna is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 52
Find For Mins

Hello ,


In addition to the problem , if i want to find and remove the files made in last 5 mins then what will be the command as , i have searched for many coomand but all depend upon days not time!!!

KRegards,
Aparna
  #6 (permalink)  
Old 11-13-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
A solution is to use the -newer expression of the find command.
  1. Compute current date/time minus 5 mn
    The Perderabo's datecalc and Simple date and time calculation in BASH may help you.
  2. Create a timestamp file with access and modification times equal to the computed date/time :
    touch -t [[CC]YY]MMDDhhmm[.SS] timestamp_file
  3. Find files newer that the timestamp file.
    find . -type f -newer timestamp_file -exec rm -f {} \;


Jean-Pierre.
Closed Thread

Bookmarks

Tags
linux, mtime

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 11:26 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