better formatting for fastdu humanreadable

This commit is contained in:
q
2018-08-12 09:26:12 +03:00
parent 1864c8acb9
commit cbc826bc8f

View File

@@ -13,7 +13,7 @@ function filesize() {
# Usage: filesize 10000
[ "$1" = "0" ] && {
echo "0 B"
echo "0 B"
return 0
}
@@ -22,7 +22,7 @@ function filesize() {
for(i=7;y < 1;i--)
y = x / (2^(10*i))
str=int(y*10)/10 " " type[i+2]
if (x==0) { str = "0 B" }
if (x==0) { str = "0 B" }
print str
}' || return $?
}
@@ -87,9 +87,14 @@ if [[ "$SUMMARY" -eq 1 ]]; then
# Display one line
processfolder "${what[@]}"
else
if [[ "$HUMAN" -eq 1 ]]; then
FORMAT="%8s %s\n"
else
FORMAT="%d\t%s\n"
fi
# One size for each argument
for dir in "${what[@]}"; do
printf "%s\t%s\n" "$( processfolder "$dir" )" "$dir"
printf "$FORMAT" "$( processfolder "$dir" )" "$dir"
done
fi