LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2008, 01:19 PM   #1
nooks12
LQ Newbie
 
Registered: Jan 2008
Posts: 1

Rep: Reputation: 0
deleting by date a specific range of files


Hi,

I'd like to go further than deleting files after a certain date i.e.

find . -mtime +30 -exec rm {} \;

and have instead a time frame defined for deleting. For example, I have some file from Sept 2006 only that I want to delete and to keep files that are older than that.

Can anyone help me?

Thanks in advance!
 
Old 01-08-2008, 02:36 PM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Well, I'm not exactly sure how many days ago Sept 2006 was, but:

Code:
find . -mtime [numberOfDays] -exec ls -lad {} \;
Should work if you replace [numberOfDays] with the correct value of the day in question and "ls -lad" with the rm once you have tested.

HTH

Forrest
 
Old 01-08-2008, 02:45 PM   #3
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
I may have misread what you were asking. You can also do something like:

Code:
find . -mtime +[numberOfDaysToSept312006] -mtime -[numberOfDaysToSept012006] -exec ls -lad {} \;
HTH

Forrest
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Best program for deleting files after than a certain date? hbbtstar Linux - Software 2 06-18-2007 10:38 AM
Deleting files after x days from the latest date file sriramsreedhars Programming 8 03-03-2007 09:30 AM
deleting files containing a specific word Sleb Programming 5 05-25-2006 01:19 PM
Script for deleting files based on date MaverickApollo Linux - General 3 02-03-2004 07:54 PM
Copying files from a specific date dman65 Linux - Software 3 09-22-2003 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration