Click here for important information about

Sorting found files by timestamp...

October 13, 2010 at 15:39:07
Specs: Unix KSH
Please forgive the possibly ignorant question - I've been searching (here and elsewhere) and haven't found this addressed, so I thought I'd give it a shot.

If I want to find a certain files in a directory, and sort by timestamp, I can simply do the following: ls -lrt filename* - that's all well and good.

The problem is I have some directories that have too many files for ls to handle. To find those filenames, I'm forced to use the "find" command. I can then use the -exec ls -ll {} to get the timestamp of all files found - but the resulting list is NOT sorted.

Is there some quick and elegant way to accomplish this that I'm overlooking? Yes, I know I could dump the find output to a file, and code up a fairly short script to interpret the dates and sort accordingly. But I was wondering if there's something more obvious. My ls -ll dates are in the "Aug 04 2010" format which precludes piping to simple sort command - if there was some way for this to be returned in a YYYYMMDD format that would be a good solution too.

Any ideas? This question must come up from time to time, which is why I'm kind of surprised I couldn't find anything.

Any help/ideas/suggestions greatly appreciated.


See More: Sorting found files by timestamp...

October 13, 2010 at 20:49:26
Hopefully, the xargs command will prevent the ls command from overflowing:

find . -type f -print|xargs ls -lrt

Report •
Related Solutions

Ask Question