3 ms·
By size: python -c 'import os; \ os.write(1, b"\0".join( \ sorted(os.listdir(b"."), key=lambda p: os.stat(p).st_size)))' \ | xargs -0 ... By dat
by loeg 7y ago
By size:
python -c 'import os; \
os.write(1, b"\0".join( \
sorted(os.listdir(b"."), key=lambda p: os.stat(p).st_size)))' \
| xargs -0 ...
By date: swap st_size for st_mtime.
(Python3 does try to make this hard on us — Unix path names are just bags of bytes, but Python insists that printing must have some known encoding. I get around that by abusing os.write(1, ...) and by adding the dummy b"." argument to os.listdir(), which forces the results to be in bytes format.)