I am writing a simple helper function to show a specific folder in the format I want:
find . -maxdepth 1 -not -name "." -printf '[%TY-%Tm-%Td]\t%s\t%f\n' | sort -n
However I want to show the filesizes in a nicer format. I found this answer which I used to create a bash function called hr
.
user@host:~$ hr 12345
12M
I tried using this in the find
call as so:
find . -maxdepth 1 -not -name "." -printf '[%TY-%Tm-%Td]\t'$(hr %s)'\t%f\n' | sort -n
But it still continues to show the full filesize. How should I modify this so it works as expected?
-exec stat {} +
with desired format instead of-printf
– Costas Oct 08 '15 at 08:45