LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to Find and remove 7 days before modified/created files (http://www.linuxquestions.org/questions/linux-software-2/how-to-find-and-remove-7-days-before-modified-created-files-642238/)

neel.gurjar 05-14-2008 08:09 PM

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

chrism01 05-14-2008 08:14 PM

man find
find /somedir -mtime +7 .....

eggixyz 05-14-2008 09:17 PM

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


All times are GMT -5. The time now is 02:16 AM.