Reputation: 5856
Looking for generic way how to sort a random list of files by its modification time, so something like:
./make_list_of_files | some_sorter_by_mtime
my currect solution is (here the make_list_of_files
is the find
command):
find / -type f -print |\
perl -nle 'push @in,$_;END {@out = sort{ (stat($a))[9] <=> (stat($b))[9] } @in; $,="\n";print @out}'
exists some simpler solution (e.g. without perl)?
Upvotes: 3
Views: 296
Reputation: 63922
Your some_sorter_by_mtime
should be for example:
xargs stat -f "%m %N" | sort -n | cut -f2-
the idea behind is:
so,
find / -type f -print | xargs stat -f "%m %N" | sort -n | cut -f2-
Upvotes: 6
Reputation: 3643
Like this?
find / -type f -print | xargs ls -l --time-style=full-iso | sort -k6 -k7 | sed 's/^.* \//\//'
Upvotes: 2