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

Re: Sorting by date



On 02/28/2011 03:25 PM, Boyd Stephen Smith Jr. wrote:
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.


That's an awful lot of effort when ls has a "sort by date" argument.

--
I prefer banana-flavored energy bars made from tofu.


Reply to: