Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find files that are older than 90 days 1

Status
Not open for further replies.

mkw77

Technical User
Jun 9, 2009
9
GB
Can anyone help please. I am trying to find files that are older than 90days in a directory and subsequent directory within. Anyone have any ideas how I might do this.

I think I may need to use the find command along with touching a file which current date in some kind of ls loop.

e.g
directory A
within directory A there are subsequent directorys say B,D,E,F etc
I need to find all files in these directories that are older than 90 days.

thanks in advance
 
Homework or other school assignment? No can do... :-(
 
at the moment I am doing:-

cd into each directory then
ls -ltr | grep " 2003 " > free.sh
ls -ltr | grep " 2004 " >> free.sh
etc
then doing the same for files which have months e.g.

ls -ltr | grep " Mar " >> free.sh
etc..

Then using awk - print getting the file name
using vi editor to place an rm infront of each file

then running my script free.sh
so the script looks like this.

rm file1
rm file2
rm file3
etc

what I am asking is, if there is another quicker way to do this.

thanks

 
find dirA -type f -mtime +90 -ok rm {} \;

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
There's a neat site on the internet for answers to these mind-boggling questions...

[google]unix find files days old[/google]



HTH,

p5wizard
 
Thanks for your help - all sorted now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top