[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sort RFE: autodetect date field and sort by date

From: Bob Proulx
Subject: Re: sort RFE: autodetect date field and sort by date
Date: Thu, 22 Oct 2009 16:32:14 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Dave!

Dave Yost wrote:
> It would be nice to be able to sort data like this by date:
> Oct 21 00:30:01 ip2 newsyslog[13756]: logfile turned over
> Jan 18 02:50:11 ip2 com.apple.launchd.peruser.502[710]
> There could be a sort command option that tells sort to make a best  
> effort to identify date fields, parse them as a date, then sort by date. 
> For cases where that doesn't work, then there could be argument that 
> allows the user to specify how to find the date text in the input.

Try this sort invocation:

  sort -s -k 1,1M -k 2,2n -k 3,3

See the -M, --month-sort documentation in the manual.

       An initial string, consisting of any amount of blanks, followed by
       a month name abbreviation, is folded to UPPER case and compared in
       the order `JAN' < `FEB' < ... < `DEC'.  Invalid names compare low
       to valid names.  The `LC_TIME' locale category determines the
       month spellings.  By default a blank is a space or a tab, but the
       `LC_CTYPE' locale can change this.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]