Article View: comp.unix.programmer
Article #47Re: Fast Removal
From: Michael Salmon
Date: Wed, 04 Nov 1992 09:30
Date: Wed, 04 Nov 1992 09:30
27 lines
1437 bytes
1437 bytes
In article <1992Nov3.011322.5994@news.eng.convex.com>, Tom Christiansen <tchrist@convex.COM> writes:
|> From the keyboard of errant@polari.online.com:
|> :In C, how would I quickly remove all files that were not created today??
|>
|> main() {
|> system("find . -mtime +1 -exec /bin/rm -f {} \\;");
|> }
I guess that solution depends upon your definition of today. Here is
the solution in sh, translation to c is left to the reader:
/usr/5bin/touch `date '+%m%d00'` /tmp/midnight
find . -type f ! -newer /tmp/midnight -exec /bin/rm -f {} \;
This relies upon a system V touch being available and is in fact not
quite correct as files created at midnight will also be deleted.
--
Michael Salmon
#include <standard.disclaimer>
#include <witty.saying>
#include <fancy.pseudo.graphics>
Ericsson Telecom AB
Stockholm
Technical Details
Message-ID:
<1992Nov4.093019.12560@ericsson.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!ericom!eos.ericsson.se!etxmesaReferences:
<1992Nov2.131951.27830@polari> <1992Nov3.011322.5994@news.eng.convex.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!ericom!eos.ericsson.se!etxmesa From: etxmesa@eos.ericsson.se (Michael Salmon) Subject: Re: Fast Removal Message-ID: <1992Nov4.093019.12560@ericsson.se> Keywords: Fast Removal Sender: news@ericsson.se Nntp-Posting-Host: eos6c02.ericsson.se Reply-To: etxmesa@eos.ericsson.se (Michael Salmon) Organization: Ericsson Telecom AB References: <1992Nov2.131951.27830@polari> <1992Nov3.011322.5994@news.eng.convex.com> Date: Wed, 4 Nov 1992 09:30:19 GMT Lines: 27