The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
delete all but one files in a directory finalight Shell Programming and Scripting 10 05-21-2008 03:51 AM
How to Delete Multi Directory and Files cthinh UNIX for Dummies Questions & Answers 5 05-08-2008 04:03 AM
Is there anyway to delete a directory that has more than 200mil files? plcyber UNIX for Advanced & Expert Users 4 06-01-2007 04:28 PM
delete files in specific directory legato Shell Programming and Scripting 2 03-29-2006 09:46 PM
CRON. How to delete files within a directory southoxon UNIX for Dummies Questions & Answers 1 08-24-2003 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-11-2006
siva80_cit siva80_cit is offline
Registered User
  
 

Join Date: May 2006
Posts: 2
Delete Some Old files from Particular Directory

Hi Team,
I am new to scripting. I want to create a script, which needs to keep only 5 days directories and want to remove the old directory from a particular directory. Can Somebody help me with starting this script.

All my directories will be created in the name <YYYYMMDD>.

Thanks in Advance..

Rgds,
Siva
  #2 (permalink)  
Old 12-11-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
try this

find /path -type d -ctime +5 -name '[0-9]{8}*' -print |xargs rm -i

give the full path in the place of /path .

this will take the creation date and time of the folders.
  #3 (permalink)  
Old 12-11-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
result part-2

Suppose if u have created a new file or did some manipulation of files in your folder YYYYMMDD and to delete those folders then u have to use
-mtime instead -ctime.

-mtime -->modification time
-ctime -->last change file time.
Sponsored Links
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 07:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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