[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sorting by date



On Monday 28 February 2011 14:35:26 erikmccaskey64 wrote:
> Original:
> Jan 23 2011 10:42 SOMETHING 2007.12.20.avi
> Jun 26 2009 SOMETHING 2009.06.25.avi
> Feb 12 2010 SOMETHING 2010.02.11.avi
> Jan 29 2011 09:17 SOMETHING 2011.01.27.avi
> Feb 11 2011 20:06 SOMETHING 2011.02.10.avi
> Feb 27 2011 23:05 SOMETHING 2011.02.24.avi
> 
> 
> Output:
> Feb 27 2011 23:05 SOMETHING 2011.02.24.avi
> Feb 11 2011 20:06 SOMETHING 2011.02.10.avi
> Jan 29 2011 09:17 SOMETHING 2011.01.27.avi
> Jan 23 2011 10:42 SOMETHING 2007.12.20.avi
> Feb 12 2010 SOMETHING 2010.02.11.avi
> Jun 26 2009 SOMETHING 2009.06.25.avi
> 
> 
> How could I get the output where the newest file is at the top?

First, pre-process the original to use ISO-standard date format: %Y-%m-%d.  
That's 4-digit year, dash, 2-digit month, dash, 2-digit day.

Now, (LC_ALL=C sort < input.pp > output.pp) will give you things sorted.  
Reverse the pre-processing to have "pretty" dates if you like.

(One of the big reasons I tell almost everything on my computer to use ISO 
standard date strings is because they string sort the same way they date 
sort.)
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: