Computing.Net > Forums > Unix > Date Sorting

Date Sorting

Reply to Message Icon

Original Message
Name: Blaise
Date: July 9, 2008 at 20:46:29 Pacific
Subject: Date Sorting
OS: UNIX Sun Solaris
CPU/Ram: NA
Model/Manufacturer: NA
Comment:

Hi there,

Im doing a date sort for the following using:
sort -k4,4 -k3,3M -k2,2 -k5,5
(Sorting by year, month, date then time)

john 12 Jul 2008 23:30
grace 19 Apr 2008 23:30
mary 01 Jun 2008 01:00
tim 20 Apr 2009 22:00
steven 19 Apr 2008 23:01
henry 17 Aug 2008 11:00

This works out perfectly but i cant seem to sort them in reverse order. I tried slotting in -r and -rk but doesnt seem to work. Any idea how can i get my command to sort in reverse order? Pls help - thanks.


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: July 9, 2008 at 23:35:21 Pacific
Reply: (edit)

This works on Solaris 9, ksh:


sort -r -k 4,4 -M -k3,3 -k 2,2 -k 5,5 sortdata

I think the placement of -M is important.


Report Offensive Follow Up For Removal

Response Number 2
Name: Blaise
Date: July 13, 2008 at 20:28:10 Pacific
Reply: (edit)

Great stuff nails, thanks! :)


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Date Sorting

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge