Aqui está um script bash / awk para isso:
#!/bin/bash
find . -type f -printf '%s\n' | awk '
function ceil(number) {
if (number == int(number)) {
return (number);
}
return int(number) + 1;
}
function ceilWithUnit(number, unit) {
return ceil(number / unit) * unit;
}
BEGIN {
blockSize = 32 * 1024;
fileSizeSum = 0;
diskUsage = 0;
}
{
diskUsage += ceilWithUnit($0, blockSize);
fileSizeSum += $0;
}
END {
printf("File count: %u\n", NR);
printf("Average size: %.2f KB\n", fileSizeSum / NR / 1024);
printf("Disk usage with %d bytes blocks: %.2f MB\n", blockSize, diskUsage / 1024 / 1024);
}
'