https://unix.stackexchange.com/a/240424/674 shows a way to find the three most recent changed files (directly or indirectly) under a directory.
find . -type f -exec stat -c '%Y %n' {} \; | sort -nr | awk 'NR==1,NR==3 {print $2}'
I try to find the three largest files under a directory by replacing stat -c '%Y %n'
with stat -c '%B %n'
.
but it doesn't seem to work correctly. because:
%b - Number of blocks allocated (see ‘%B’)
%B - The size in bytes of each block reported by ‘%b’
My guess is that %b
doesn't report the size of a file, but I am not sure.
So what shall I do?