Date: Tue, 8 Apr 2003 21:41:04 +0200 From: Erik Trulsson <ertr1013@student.uu.se> To: David Banning <david@skytracker.ca> Cc: questions@freebsd.org Subject: Re: how to find file older than... Message-ID: <20030408194103.GA77855@falcon.midgard.homeip.net> In-Reply-To: <20030408151104.A32743@skytrackercanada.com> References: <20030408151104.A32743@skytrackercanada.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 ) -- <Insert your favourite quote here.> Erik Trulsson ertr1013@student.uu.se
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030408194103.GA77855>