Fun Scripting Problem

Teske, Devin Devin.Teske at
Wed Feb 13 18:38:16 UTC 2013

(apologies for top-post)

As tempted as I am, I think newsyslog(8) may be what you want.

Missing information in your post is how you intend to timestamp the files -- by filename? by content? If by-content, then is it a good assumption that the data is one entry per-line? ... and if-so, is the timestamp in that line? These are all questions that would be needed to script what you're asking for (not that I'm volunteering or anything like that).

From: owner-freebsd-questions at [owner-freebsd-questions at] on behalf of Tim Daneliuk [tundra at]
Sent: Wednesday, February 13, 2013 10:27 AM
To: FreeBSD Mailing List
Subject: Fun Scripting Problem

I know how to do this in Python, but I really want to do it in
straight Bourne shell.  I have some ideas, but I thought I'd
give you folks a crack at this Big Fun:

a)  You have a directory of files - say they're logs - generated
     at nondeterministic intervals.  You may get more than one a day,
     more than one a month, none, or hundreds.

b) To conserve space, you want to keep the last file generated
    in any given month (the archive goes back for an unspecified
    number of years), and delete all the files generated prior to
    that last file in that same month.

c) Bonus points if the problem is solved generally for either files
    or directories generated as described above.

These are not actually logs, and no, I don't think logrotate can
do this ... or can it?

Tim Daneliuk
freebsd-questions at mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at"

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.

More information about the freebsd-questions mailing list