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

Re: Sorting by date



On 02/28/2011 03:55 PM, Boyd Stephen Smith Jr. wrote:
On 2011-02-28 15:40:18 Ron Johnson wrote:
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.

Perhaps this isn't the output of ls?  Perhaps instead this is copy-and-pasted
output from the web interface of a video monitoring appliance that requires
moonlight to use?

If the OP just wanted the output for ls sorted, why not just ask for that
instead of giving us examples that don't look like the output of ls.  (Yeah,
GNU ls can probably look like that with a command-line full of options, but
it's not one of the few UNIX ls output styles.)

Because the time portion of the "Feb 12 2010" and "Jun 26 2009" aren't there, to me it *does* look like ls output with the protections, ownership and size removed so that it'll fit in an email.

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


Reply to: