Fun Scripting Problem
freebsd-questions-local at be-well.ilk.org
Wed Feb 13 19:07:20 UTC 2013
Tim Daneliuk <tundra at tundraware.com> 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.
More information about the freebsd-questions