LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-14-2008, 07:09 PM   #1
neel.gurjar
LQ Newbie
 
Registered: Apr 2008
Posts: 20

Rep: Reputation: 0
How to Find and remove 7 days before modified/created files


Hi,

On my linux machine I have one folder and there some temporary files get created daily. I want to create one script or command which will delete all files which are created/modified before 7 days.
Here I want to keep last 7 days files.

Please help
Thanks
Neelesh
 
Old 05-14-2008, 07:14 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
man find
find /somedir -mtime +7 .....
 
Old 05-14-2008, 08:17 PM   #3
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Just in case you start getting errors (although that's all you'll get because if you just use rm it won't remove directories), but you could add

-type f

in your find parameters to avoid the "cannot delete blah: directory" type errors.

Best wishes,

Mike
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
which files have modified in the last few days ? varun_saa Mandriva 6 03-10-2007 10:34 AM
how to list all files modified in last N days sneakyimp Linux - General 3 07-28-2006 12:16 PM
Find all files created or modified between 2 times MicahCarrick Linux - Software 3 06-29-2006 04:22 PM
remove a folder created 3 days ago. eduac Linux - Software 4 10-17-2005 11:15 AM
Tar files in a dir modified before 7 days in a shell script jayachristina Linux - Newbie 4 05-14-2004 02:49 AM


All times are GMT -5. The time now is 09:34 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration