Originally Posted by jschiwal
Do you want to sort simply by the basename? You could use find instead. This example prints two entries per file, the basename and the full pathname and then uses sort to sort the output:
find ./ -type f -printf "%f\t%p\n" | sort
I want to sort by file size, and also sometimes by modification date. And so based on that, this works for file size:
find ./ -iname '*.gif' -type f -printf "%s\t%p\n" | sort -r -n
And also for sorting by modification change time:
find ./ -iname '*.gif' -type f -printf "%T@\t%t\t%p\n" | sort -r -n
Originally Posted by Tinkster
find . -iname \*gif -ls | sort -k 7,7 -k 11,11
Finds all, sorts by size, then directory/name
Yes that works
(with -r added to sort) One problem is that filesize is printed in 1K blocks.
I prefer the find...-ls format to using -printf, but can -ls format be done with raw file size rather than file size in 1K blocks?
And is there any way to use the -ls format to sort by modification change time/status change time etc.?