"du -h" with more decimal places
du -Lsbc * | awk '
function hr(bytes) {
hum[1024**4]="TiB";
hum[1024**3]="GiB";
hum[1024**2]="MiB";
hum[1024]="kiB";
for (x = 1024**4; x >= 1024; x /= 1024) {
if (bytes >= x) {
return sprintf("%8.3f %s", bytes/x, hum[x]);
}
}
return sprintf("%4d B", bytes);
}
{
print hr($1) "\t" $2
}
'
awk-function based on this.
One could probably make the output look a bit nicer by piping it through column
or left-padding it with spaces.
Edit: Added the left-padding.
Also, to sort the list: du -Lsbc * | sort -n | awk
and then the awk-script.