D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Sort blocks of lines

 

Hello everyone.
I'm looking for a slightly more advanced sort command. I have 2 extra 
things it needs to do. Firstly, it needs to be able to sort a file based 
on a date which looks a bit like this:
Tue Jan  8 04:53:47 GMT 2008  [and some other info which should be ignored]

Not particularly nice. I'm sure PHP's strtotime function would probably 
be able to read that, but I need something I can use in a shell script.

Secondly, the file is in the format:
date/time as above
arbitrary text
blank line

In this particular case the arbitrary text is all on one line so all I 
need to do is somehow convince the sort command to move blocks of 3 
lines around, but being able to tell it to move everything up to and 
including a blank line would also be nice.

Any ideas?
Thanks.
Simon

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html