[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] "ls -lh" rounds up the size of files instead of rounding
From: |
Eric Blake |
Subject: |
Re: [coreutils] "ls -lh" rounds up the size of files instead of rounding half up/down. |
Date: |
Mon, 10 Jan 2011 14:21:08 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 |
[re-adding the list, to publicize your request. Also, it's nicer to
avoid top-posting on technical lists]
On 01/10/2011 02:14 PM, crocket wrote:
> Can you add an option to round half up/down?
> There are times when users want to see close approximation rather than safely
> rounded up sizes.
You are welcome to submit such a patch yourself. Personally, rounding
up doesn't bother me, so I'm unlikely to take the time to write such a
patch myself when I have other more-pressing issues to tackle.
>> However, rounding half down/up is much more common than rounding up in the
>> real
>>
>>
>> world.
>> When I expect moderate file size approximation, this 1GB difference is not
>> ignorable.
>>
>> Is there any reason for this behavior?
>
> Yes. -h is a GNU extension, but the comparable -k and -s options have
> behavior specified by POSIX. And POSIX requires that these options
> round up to the next integral number of units.
Meanwhile, if I'm really concerned about disk usage, I find 'df' to be
much more accurate than 'ls -l'; likewise, if quotas are a concern, I
find quota-specific tools to be more reliable than ls -l. Sparse files
and hard links both come into play when determining disk usage, and
using 'ls' or 'du' to estimate disk usage is already inherently
inaccurate when compared to actually asking the operating system about
free disk space via 'df'.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature