From owner-freebsd-questions@FreeBSD.ORG Wed Feb 13 19:07:20 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D6A83B54 for ; Wed, 13 Feb 2013 19:07:20 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id A69359C0 for ; Wed, 13 Feb 2013 19:07:20 +0000 (UTC) Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.41]) by be-well.ilk.org (Postfix) with ESMTP id D018633C1D; Wed, 13 Feb 2013 14:07:14 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 922E939843; Wed, 13 Feb 2013 14:07:13 -0500 (EST) From: Lowell Gilbert To: tundra@tundraware.com Subject: Re: Fun Scripting Problem References: <511BDB13.3060005@tundraware.com> <13CA24D6AB415D428143D44749F57D7201EA7EBB@ltcfiswmsgmb21> <511BE12C.204@tundraware.com> Date: Wed, 13 Feb 2013 14:07:13 -0500 In-Reply-To: <511BE12C.204@tundraware.com> (Tim Daneliuk's message of "Wed, 13 Feb 2013 12:53:32 -0600") Message-ID: <44pq04f2xq.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: FreeBSD Mailing List X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2013 19:07:20 -0000 Tim Daneliuk writes: > On 02/13/2013 12:38 PM, Teske, Devin wrote: >> (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). >> > > The only way to determine the date of the file is by looking at its > stat info. There is nothing the file name or content that could > be used to infer this. Well, you can use stat to output the year, month, timestamp, and file name in a fixed format for all of the files, sort them, and then cycle through the list, deleting every file that has a year and month that are the same as the following one in the list. The looping can be done with sh "read" or with sed.