3 ms·
Another alternative find /etc/ -mindepth 1 -maxdepth 1 -type f \ -printf '%s:%T@:%p\000' \ | sort -z -t: -k1,1g \ | sed -E -z 's/^[0-9]+:[0-9.]+:
by ailideex 7y ago
Another alternative
find /etc/ -mindepth 1 -maxdepth 1 -type f \
-printf '%s:%T@:%p\000' \
| sort -z -t: -k1,1g \
| sed -E -z 's/^[0-9]+:[0-9.]+://g' \
| tr '\000' '\n'
Sorts by size, can just change -k1,1 to -k2,2 to sort by date. Tested on fedora 31 with gnu find, sed, sort and tr.
And really the answer given at the stackexchange link is quite on point:
> However ls is really a tool for direct consumption by a human, and in that case further processing is less useful. For futher processing, find(1) is more suited.
Find is the right solution, find gives you an enormous amount of control, to re-implement find in ls seems counter productive.