13
3
How do I list all files under a directory recursively and sort the output by modification time?
I normally use ls -lhtc
but it doesn't find all files recursively. I am using Linux and Mac.
ls -l
on Mac OS X can give
-rw-r--r-- 1 fsr user 1928 Mar 1 2011 foo.c
-rwx------ 1 fsr user 3509 Feb 25 14:34 bar.c
where the date part isn't consistent or aligned, so a solution have to take this into account.
Partial solution
stat -f "%m%t%Sm %N" ./* | sort -rn | head -3 | cut -f2-
works, but not recursively.
I'm going to assume you are on Linux, but you should specify your OS explicitly either in the question or preferably in as a tag. – EBGreen – 2012-04-24T18:44:22.560