Re: Sorting according to date



$ 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/

.



Relevant Pages

  • Re: Sorting according to date
    ... What is the easiest way to sort the file according to date? ... I was thinking of the brute force way: Extracting the individual ... Ronald Fischer ... Ruby is an excellent choice. ...
    (comp.unix.shell)
  • Re: Sorting according to date
    ... What is the easiest way to sort the file according to date? ... I would likely do this in Perl or Ruby because of better ... Ronald Fischer ...
    (comp.unix.shell)
  • Re: Sorting according to date
    ... PDreyer wrote: ... Ronald Fischer wrote: ... What is the easiest way to sort the file according to date? ... I was thinking of the brute force way: ...
    (comp.unix.shell)
  • Re: Sorting according to date
    ... forgot to sort and display in original format ... What is the easiest way to sort the file according to date? ... Ronald Fischer ...
    (comp.unix.shell)
  • Re: I know you guys would hate me for this.... (spoof because this has gone on just about long enoug
    ... Ibn al-Hazardous wrote: ... cats because he was not comfortable with being reborn as a cat, ... claimed not being able to regard online people as friends. ... sort of like degrees of separation from Kevin Bacon. ...
    (rec.games.computer.ultima.dragons)