16 lines
280 B
Bash
16 lines
280 B
Bash
|
human_readable_size() {
|
||
|
local bytes="$1"
|
||
|
local sizes=("B" "KB" "MB" "GB" "TB" "PB" "EB" "ZB" "YB")
|
||
|
|
||
|
local i=0
|
||
|
while ((bytes > 1024)); do
|
||
|
((bytes /= 1024))
|
||
|
((i++))
|
||
|
done
|
||
|
|
||
|
printf "%d%s" "$bytes" "${sizes[i]}"
|
||
|
}
|
||
|
|
||
|
human_readable_size $1
|
||
|
echo ""
|