Date: Mon, 29 Jan 2001 16:25:21 -0600 From: Lucas Bergman <lucas@slb.to> To: Peter Brezny <peter@sysadmin-inc.com> Cc: freebsd-questions@freebsd.org Subject: Re: find shell script problem Message-ID: <20010129162521.F17961@billygoat.slb.to> In-Reply-To: <006101c08a3f$e6f40b60$46010a0a@sysadmininc.com>; from peter@sysadmin-inc.com on Mon, Jan 29, 2001 at 05:07:41PM -0500 References: <006101c08a3f$e6f40b60$46010a0a@sysadmininc.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> I would like to be able to automatically delete directories within a > single subdirectory once they are more than three months old. > > I've been reading the man page for date and find and have some ideas > but am lacking in shell scripting knowledge. > > my best attempt (which doesn't work) is: > > find /dir1/ \! -newer `date -v-3m` -delete > > This however returns the actual date 3 months ago rather than the > date of any directory 3 months ago. I don't know how to tell find > to apply this date to any directory it finds under /dir1/ Use the '-mtime' or a similar option on `find'. Something like % find /dir1 -type d -mtime +90 | xargs rm -rf is probably what you want. Take care that you don't delete the top-level directory, though. Lucas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010129162521.F17961>