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?
On Mon, Feb 28, 2011 at 2:35 PM, erikmccaskey64 erikmccaskey64@zoho.com wrote:
How could I get the output where the newest file is at the top?
One solution would be to awk it until the date is in the format Europeans prefer, namely YYYY MM DD.
regards/vaden@texoma.net
On Mon, Feb 28, 2011 at 2:37 PM, Larry Vaden vaden@texoma.net wrote:
On Mon, Feb 28, 2011 at 2:35 PM, erikmccaskey64 erikmccaskey64@zoho.com wrote:
How could I get the output where the newest file is at the top?
One solution would be to awk it until the date is in the format Europeans prefer, namely YYYY MM DD.
That said, are you really looking for the package with the latest E-V-R; if so, you'll need to borrow Python code from yum or perhaps a Python guru on this list.
Johnny at CentOS (IMHO) recently posed this question as a way of filtering out wanna be helpers.
regards/vaden@texoma.net
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?
Don't suppose these are in a directory and modification date has been preserved, are they? Because "ls -t" is your friend.
Otherwise run ls output through a tiny perl program and convert to YYYYMMDDHHMM names and hard link the old name to the new.
On Fri, Mar 4, 2011 at 2:38 PM, Bill Davidsen davidsen@tmr.com wrote:
Don't suppose these are in a directory and modification date has been preserved, are they? Because "ls -t" is your friend.
And "ls -lht" will give you the long listing with the last modified dates.
On Fri, 2011-03-04 at 22:26 -0800, suvayu ali wrote:
On Fri, Mar 4, 2011 at 2:38 PM, Bill Davidsen davidsen@tmr.com wrote:
Don't suppose these are in a directory and modification date has been preserved, are they? Because "ls -t" is your friend.
And "ls -lht" will give you the long listing with the last modified dates.
I find "ls -last" easy to remember.
poc
On 04Mar2011 17:38, Bill Davidsen davidsen@tmr.com wrote: | 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? | > | Don't suppose these are in a directory and modification date has been | preserved, are they? Because "ls -t" is your friend. | | Otherwise run ls output through a tiny perl program and convert to | YYYYMMDDHHMM names and hard link the old name to the new.
Or if perl/programming is tricky, GNU date will handle those leading words:
ls \ | while read -r f do set -- $f iso=`date +%Y%m%d-%H%M%S -d "$1 $2 $3"` echo "$iso $f" done \ | sort \ | sed 's/^[^ ]* //'
which reads the filenames, uses the date command to make an ISO8601 date from the first three words or each, puts it on the front of the line, sorts the output (ISO dates are VERY handy for this), and then strips the ISO date off the lines after the sort, leaving the filenames.
Cheers,