Article View: news.software.nntp
Article #14461Re: Very old articles.
From: Jonathan I. Kamens
Date: Mon, 27 Jan 1997 00:00
Date: Mon, 27 Jan 1997 00:00
41 lines
2557 bytes
2557 bytes
In article <5casfi$9gn@ednet2.orednet.org>, dkotte2@orednet.org (Daryl E. Kottek) writes:
|> ASSUMPTION: You don't want ANY articles that are older than 3 months old.
|> touch 1024000096 /tmp/old
|> This creates a file called /tmp/old with a date of 10/24/96 00:00
|>
|> cd /var/spool/news
|> find . -type f -name "[0-9]*" ! -newer /tmp/old -print -exec rm {} \;
|> This finds all files that are plain files in which the name of the
|> file is composed of only digits and is older than the date of the
|> file called /tmp/old (you set that up to be 10/24/96). With the
|> files that match this criteria, it will print their names, and
|> also remove them.
First of all, you are assuming that this individual has a version of
touch which allows the file modification time to be specified as you
have indicated. That is certainly not true for all UNIX variants.
E.g., it's not true for Linux (assuming that GNU touch is being used),
which requires the "-t" flag to specified before the timestamp, or for
SunOS 4.x, which doesn't allow the timestamp to be specified to touch
at all.
Second, there's absolutely no reason to use a touched file as you've
suggested to tell find which files to delete. Using "-mtime +90" is
sufficient.
Third, the find file-name pattern "[0-9]*" will not, as you have
claimed, find files "in which the name of the file is composed of only
digits." It will find files whose names *start with a digit*. The
difference in this case is minimal, but if you're going to give an
example showing people how to use find, you ought to get it right.
Fourth, having find invoke rm individually for each file being removed
is inefficient, and this will make a difference if there are lots of
old files. Using "find . -type f -mtime +90 -print | xargs rm -f" is
much more efficient.
--
Jonathan Kamens | OpenVision Technologies, Inc. | jik@cam.ov.com
Technical Details
Message-ID:
<5cidfn$q00$1@pad-thai.cam.ov.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<Pine.LNX.3.93.970123165601.27532A-100000@jason.interalpha.net> <5casfi$9gn@ednet2.orednet.org>Show Full Headers
Complete Article Headers
Message-ID: <5cidfn$q00$1@pad-thai.cam.ov.com> Subject: Re: Very old articles. Date: Mon, 27 Jan 1997 00:00:00 +0000 From: jik@cam.ov.com (Jonathan I. Kamens) References: <Pine.LNX.3.93.970123165601.27532A-100000@jason.interalpha.net> <5casfi$9gn@ednet2.orednet.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 212522818 Distribution: inet Organization: OpenVision Technologies, Inc. Newsgroups: news.software.nntp