du 的输出错误?

Ger*_*nsa 15 disk-usage

我认为我的 du 命令很混乱。

% du -shc DIR ...
...
6123941496      total

% du -shc DIR ...
...
6.1G    total

% du -sc --si DIR ...
...
6.6G    total
Run Code Online (Sandbox Code Playgroud)

我试过LANG=C在电子表格中给出并仔细检查结果。看起来 -h 已经使用 1000 (--si) 的幂进行输出,而 --si 给出了错误的答案。我认为正确的答案应该是 -h 的 5.7G 和 --si 的 6.1G。那么这里会发生什么呢?

% du --version
du (GNU coreutils) 8.20
...

% uname -a
Linux XXX 3.9-1-amd64 #1 SMP Debian 3.9.8-1 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

slm*_*slm 20

使用--apparent-size开关重复您的测试。

$ du -shc --apparent-size DIR ...
Run Code Online (Sandbox Code Playgroud)

摘自 du 手册页

--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
Run Code Online (Sandbox Code Playgroud)