Re: Sorting according to date
- From: "PDreyer" <petrus.dreyer@xxxxxxxxx>
- Date: 7 Jul 2006 05:19:48 -0700
$ cat f1
06-Jul.16:30 ....
26-Jun.16:20 ....
06-Jun.16:30 ....
16-Feb.16:30 ....
16-Feb.16:29 ....
16-Feb.06:31 ....
$ sed 's/-/ /;s/\./ /' f1 | sort -k 2M -k 1n -k 3,3 | sed 's/ /-/;s/
/\./'
16-Feb.06:31 ....
16-Feb.16:29 ....
16-Feb.16:30 ....
06-Jun.16:30 ....
26-Jun.16:20 ....
06-Jul.16:30 ....
-----Original Message-----
Ronald Fischer wrote:
The lines in a text file start with the following, somewhat exotic,
date specification:
06-Jul.09:58 .....
06-Jul.14:10 .....
13-Jun.09:27 .....
What is the easiest way to sort the file according to date?
I was thinking of the brute force way: Extracting the individual
parts, mapping month names to numbers, putting together from the
result a suitable number, and sort the beast numerically (and
I would likely do this in Perl or Ruby because of better
pattern matching abilities).
But maybe someone has an idea how to do it easily on shell level?
I was already thinking of using 'sort', but we don't have a
unique field delimiter here (-.: ).
Ronald
--
Ronald Fischer <ronaldf@xxxxxx>
Posted via http://www.newsoffice.de/
.
- Follow-Ups:
- Re: Sorting according to date
- From: Jon LaBadie
- Re: Sorting according to date
- References:
- Sorting according to date
- From: Ronald Fischer
- Sorting according to date
- Prev by Date: Re: Sorting according to date
- Next by Date: Re: how to control the output columns?
- Previous by thread: Re: Sorting according to date
- Next by thread: Re: Sorting according to date
- Index(es):
Relevant Pages
|