[Wlug] inconsistent results with du and multiple arguments

Chuck Anderson cra at WPI.EDU
Wed Jun 18 10:35:22 EDT 2008


On Wed, Jun 18, 2008 at 10:20:08AM -0400, Brett Russ wrote:
> Thanks Mike, looks like it is related to the -x argument:
> http://www.mail-archive.com/bug-gnulib@gnu.org/msg04655.html
...
> Chuck,
> If it were rounding error I should still be able to make direct comparisons
> between the results, as long as they all used the -m argument.

In my tests, with or without -x didn't make a difference:

>du -smxc yum jigdo
1       yum
48      jigdo
48      total
>du -smc yum jigdo
1       yum
48      jigdo
48      total

But leaving off the -m, the total is the correct sum of the two 
directories:

>du -sxc yum jigdo
416     yum
48660   jigdo
49076   total

I think that du -mc is adding the sizes first, then converting to 1 
MiB blocks, therefore showing the approximation error in the total.

In the -m case, 416 KiB rounds to 1 MiB, 48660 KiB rounds to 48 MiB, 
but the total isn't calculated as 1 + 48, but rather as 416 KiB + 
48660 KiB = 49076 KiB, 49076 KiB / 1024 = 47.92 MiB, which rounded off 
becomes 48 MiB.


More information about the Wlug mailing list