I have the need to get information about a specific directory, basically I need to know the correlation between small, medium and big files.
I came up with this:
for i in K M G; do
printf $i
du -h /usr/opt |
awk '{print $1}' |
grep ${i}$ |
wc -l
done | tee /stat.out
from the result then I add all numbers and subtract the total to obtain the number of files under 1k. ( I presume we have a lot of them since it's source files)
Anyway, this way is good for small directories, I actually have a very big one (expecting over 1Tera) and no idea of the files distribution. I need to copy all these files to a private storage and need to give a estimate time on the copy.
I was thinking on the line of doing something as this:
find pwd |xargs ls -lph |awk '{print $5}'
But I miss what I should put after or if I should take another approach. Any help would be most welcome.


find ... -size -1k? – h3rrmiller Feb 19 at 15:14ls, and process the list of sizes? Could even do fancy histograms and other pretty images... – vonbrand Feb 19 at 15:46