From owner-freebsd-questions Mon Jan 29 14:27:50 2001 Delivered-To: freebsd-questions@freebsd.org Received: from dsl-64-193-218-89.telocity.com (dsl-64-193-218-89.telocity.com [64.193.218.89]) by hub.freebsd.org (Postfix) with SMTP id BB30D37B400 for ; Mon, 29 Jan 2001 14:27:33 -0800 (PST) Received: (qmail 4376 invoked by uid 1000); 29 Jan 2001 22:25:21 -0000 Date: Mon, 29 Jan 2001 16:25:21 -0600 From: Lucas Bergman To: Peter Brezny Cc: freebsd-questions@freebsd.org Subject: Re: find shell script problem Message-ID: <20010129162521.F17961@billygoat.slb.to> Reply-To: lucas@slb.to References: <006101c08a3f$e6f40b60$46010a0a@sysadmininc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <006101c08a3f$e6f40b60$46010a0a@sysadmininc.com>; from peter@sysadmin-inc.com on Mon, Jan 29, 2001 at 05:07:41PM -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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