List files recursively and sort by modification time
Posted
by
Problemaniac
on Super User
See other posts from Super User
or by Problemaniac
Published on 2012-04-24T18:37:09Z
Indexed on
2014/06/12
15:29 UTC
Read the original article
Hit count: 156
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.
© Super User or respective owner