Re: How to sort a file -



Bob Goodwin wrote:

I have a file of Netgear router data that I would like to sort on date and time.
the form is as below:

[Site allowed: weather.noaa.gov] from source 192.168.1.9 Saturday,
Aug 01,2009 17:02:51
[Site allowed: safebrowsing-cache.google.com] from source
192.168.1.11 Saturday, Aug 01,2009 17:00:16
[Site allowed: safebrowsing.clients.google.com] from source
192.168.1.11 Saturday, Aug 01,2009 17:00:13


The router appears to accumulate data until full and then clears at some point and starts a new block of data.
I can collect the data periodically [perhaps at 30 minute intervals, whatever works for me] and append it to a new file I called "home/bobg/NG-LOG" but this leaves me with a jumble of date/time information since the raw log data is in descending order of date/time and I am adding the latest data in the same order but at the bottom so the list it may show 16:00-15:30 followed by the latest block on the list 16:30-16:00.

I need to either sort the data as a function of time or append the new data to the beginning of the "NG-LOG" file instead of the end. I don't know where to start on this? I'm probably missing something obvious but ...

Any suggestions appreciated.

Looks like a case for a few lines of perl, and a quick call to sort for the ordering, probably the easiest fix.

See attached if the mailer doesn't eat it.

--
Bill Davidsen <davidsen@xxxxxxx>
"We have more to fear from the bungling of the incompetent than from
the machinations of the wicked." - from Slashdot

Attachment: logsort.pl
Description: Perl program

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Relevant Pages

  • How to sort a file -
    ... I have a file of Netgear router data that I would like to sort on date and time. ... information since the raw log data is in descending order of date/time and I am adding the latest data in the same order but at the bottom so the list it may show 16:00-15:30 followed by the latest block on the list 16:30-16:00. ... I need to either sort the data as a function of time or append the new data to the beginning of the "NG-LOG" file instead of the end. ...
    (Fedora)
  • Re: How to sort a file -
    ... I have a file of Netgear router data that I would like to sort on date ... information since the raw log data is in descending order of date/time ... I need to either sort the data as a function of time or append the new ...
    (Fedora)
  • Re: NAMBLA & PELOSI...the real facts
    ... experiment with VIEW and then CURRENT VIEW, and then sort by date, you ... should be able to get your threads in descending order so you can tell ... Political folks call all sorts of people names. ... politics that are unfair. ...
    (rec.gambling.poker)
  • Re: NAMBLA & PELOSI...the real facts
    ... experiment with VIEW and then CURRENT VIEW, and then sort by date, you ... should be able to get your threads in descending order so you can tell ... Political folks call all sorts of people names. ... politics that are unfair. ...
    (rec.gambling.poker)
  • Re: Guido rethinking removal of cmp from sort method
    ... that was to be sorted first according to the first item in ascending ... then according to the second item in descending order. ... By far the best result comes from two calls to sort. ... key function solution. ...
    (comp.lang.python)