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.
`-M'
`--month-sort'
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.
Bob