The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

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 01:40 AM
Script for deleting 30 days older moon_friend Shell Programming and Scripting 3 06-24-2008 09:43 AM
Deleting / finding files older than X days missess a day guruparan18 Shell Programming and Scripting 4 05-08-2008 03:09 AM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 01:40 AM
delete files older than 7 days lesstjm UNIX for Dummies Questions & Answers 1 11-06-2001 07:43 AM

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

Join Date: Nov 2007
Posts: 4
Deleting specfic files older than N days

Hello,

I am trying to delete specific files older than 7 days that start with FSTRnnnn (nnnn=sequnce number) from /home/users/userdir
I.E
cd home/users/userdir
ll
FSTR0001 Jul 8 14:20
FSTR0002 Jul 6 12:01
FSTR0003 May 25 09:45
FSTR0004 April 2 17:20
MSTR0034 Jul 6 12:45
LSTR0095 May 7 22:06

Can someone tell me how do I safely delete FSTR files.

Thank you
Reply With Quote
Forum Sponsor
  #2  
Old 07-08-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,027
Code:
find . -type f -name "FSTR????" -mtime +7 -exec rm -f {} \;
This will be recursive ie. deleting files older than 7 days matching the name convention, too. Else you might add a -prune switch into the find.
Reply With Quote
  #3  
Old 07-18-2008
Registered User
 

Join Date: Nov 2007
Posts: 4
Great, this worked. What about if there are 5 or more characters in the FSTR files.


FSTR01234Jul 8 14:20
FSTR0001 Jul 8 14:20
FSTR0002 Jul 6 12:01
FSTR0003 May 25 09:45
FSTR0004 April 2 17:20
MSTR0034 Jul 6 12:45
LSTR0095 May 7 22:06


Thank you for your help!
Reply With Quote
  #4  
Old 07-18-2008
Registered User
 

Join Date: Jul 2008
Location: Texas
Posts: 60
Use FSTR*
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 05:28 PM.


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