[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Simon Williams wrote: > 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] Steve beat me to recommending Date::Manip, but it's excellent. It'll read in a huge variety of humancentric date strings and convert to unixtime, which can then be sorted with a basic sort(); Same probably exists for other languages, maybe even bash if you wanted to avoid a called language entirely. > 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. In perl, split line into "unixdate,data\n", removing any bits you don't want and push into an array, sort it, use it. -- 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