[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "du -k" and "du -b" inconsistent output
From: |
The Wanderer |
Subject: |
Re: "du -k" and "du -b" inconsistent output |
Date: |
Thu, 19 Oct 2006 17:40:24 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 |
Miguel Barão wrote:
This not a bug but rather an inconsistent output between these two du
options, which is not documented in the manpages.
Suppose 'somefile' is a file containing a lot of zeros.
Then I get:
$ du -k somefile
12
$ du somefile
12
$ du -b somefile
4194432
It seems that du -b is returning the size of the file, and not the
"disk usage" of that file.
That's because that's part of what the -b option requests it to do.
(Using coreutils-5.94, linux on both reiserfs and ext3)
In coreutils-5.97 under Debian, this is in fact documented in the man
page (which is to say the --help output):
==
-b, --bytes equivalent to ‘--apparent-size --block-size=1’
==
and just above that
===
--apparent-size print apparent sizes, rather than disk usage;
although the apparent size is usually smaller,
it may be larger due to holes in (‘sparse’)
files, internal fragmentation, indirect blocks,
and the like
-B, --block-size=SIZE use SIZE-byte blocks
==
By contrast:
==
-k like --block-size=1K
==
The effect of the --apparent-size option is what makes the difference.
As long as I'm here: From the fact that '-b' is referred to as being
"equivalent to" its set of other options, I infer that it has precisely
the same effect as providing those other options explicitly. From the
fact that '-k' is referred to as being "like" its (single-member) set of
other options, I infer that its effect is similar but not identical to
the effect of providing that other option explicitly. (Three other
options are also referred to as being "like" another option or set of
set of options, but two of them provide explicit descriptions of what
the differences are.)
Are these inferences correct? If the latter is incorrect, what are the
differences between the two effects? If the former is incorrect, what in
the world do you think "equivalent" means? If both are correct, why are
two different terms used to describe the fact, when it would seem both
simpler and better to use the same terminology in parallel in both
cases?
--
The Wanderer does hope he hasn't just made a fool of himself in
public yet again
Warning: Simply because I argue an issue does not mean I agree with any
side of it.
Secrecy is the beginning of tyranny.