From owner-freebsd-questions@FreeBSD.ORG Tue Apr 8 12:41:09 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1D5BB37B401 for ; Tue, 8 Apr 2003 12:41:09 -0700 (PDT) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id F305443F75 for ; Tue, 8 Apr 2003 12:41:06 -0700 (PDT) (envelope-from ertr1013@student.uu.se) Received: (qmail 93146 invoked by uid 1001); 8 Apr 2003 19:41:04 -0000 Date: Tue, 8 Apr 2003 21:41:04 +0200 From: Erik Trulsson To: David Banning Message-ID: <20030408194103.GA77855@falcon.midgard.homeip.net> Mail-Followup-To: David Banning , questions@freebsd.org References: <20030408151104.A32743@skytrackercanada.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030408151104.A32743@skytrackercanada.com> User-Agent: Mutt/1.5.4i cc: questions@freebsd.org Subject: Re: how to find file older than... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Apr 2003 19:41:09 -0000 On Tue, Apr 08, 2003 at 03:11:04PM -0400, David Banning wrote: > I want to delete files that are older than 1/2 hr in a particular > directory. the only way I can think of doing it is by doing > a "test" and comparing the date to another file. I would then > have to create -that- comparison file 1/2 hour before. > > Is there an easier way? Use find(1). The version of find(1) included with FreeBSD has some quite useful features that unfortunately are not available on all other systems, but as long as you are not terribly concerned about portability of your scripts you can use them. For your particular problem the the following should work: find /path/to/directory ! -newerct '30 minutes ago' -print Once you are satisfied that the above finds the files you want, you might wish to change the '-print' into '-delete' (Oh, and to create a file that has a creation time of 30 minutes ago you can use the following: touch -t `date -j -v -30M '+%Y%m%d%H%M'` /file/name ) -- Erik Trulsson ertr1013@student.uu.se