[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: df -h shows insufficient precision



On 26.08.18 12:25, Zenaan Harkness wrote:
> A regular itchy annoyance for years now:
> 
> df shows bytes, df -h shows only one decimal place, so e.g. on a
> 1.8TiB drive "1.6T" is the free space, but that resolution/ precision
> is insufficient.

For more than 3 decades I've just used "df -k". OK, even on smaller
disks than yours, that's a lot of digits, so a bit of mental juggling:

$ df -k
Filesystem    1K-blocks     Used Available Use% Mounted on
/dev/sda9     293477416 15376432 263193184   6% /home

Better is "df -m". On larger disks, you'll have more digits than here:

$ df -m
Filesystem    1M-blocks     Used Available Use% Mounted on
/dev/sda9        286600    15017    257025   6% /home

> Of course I can fire up bc, set scale=20 and do some
> powers of 1024 division, but that's all very clunky.
> 
> How hard would it be to add an option to bc, to choose the number of
> decimal places to use in the output, or the number of digits of
> precision to display?

Harder than putting the output of df -k through two lines of awk in a
shell function, I figure.

Erik


Reply to: