Re: df -h shows insufficient precision
- Date: Sat, 25 Aug 2018 22:38:19 -0400
- From: Roberto C. Sánchez <roberto@xxxxxxxxxx>
- Subject: Re: df -h shows insufficient precision
On Sun, Aug 26, 2018 at 12:25:44PM +1000, 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. 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?
Have you looked at the -k and -B options? Also, di has the -d option
which is more flexible and it also supports format strings. You should
be able to make it produce output in exactly the way you need.
Roberto C. Sánchez