【问题标题】:How does du calculate the size of a file in kilobytes?du 如何计算文件的大小(以千字节为单位)?
【发布时间】:2014-04-16 12:13:42
【问题描述】:

我有一个文件 du -b filename 给出67108864 作为答案(应该以字节为单位), 尽管 du filename 给出 65604(应该以千字节为单位)。
但是,它应该返回 67108864/1024 = 65536 作为答案。

我查看了 du 的 man 条目,但找不到答案。
我错过了什么?

我在 64 位机器上运行 Ubuntu 12.04 版。

【问题讨论】:

    标签: du


    【解决方案1】:

    -b 不仅仅是字节:

      -b, --bytes           equivalent to `--apparent-size --block-size=1'
      --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
    

    【讨论】:

    • 非常感谢。因此,从逻辑上讲,我希望将其视为一个 67108864 字节的文件,仅此而已?
    • 我想这取决于你用它做什么。如果您正在计算需要多大的硬盘驱动器,您最好使用65604*1024。如果你想知道你可以从文件中读取多少字节,那就是67108864
    • 是的,后者。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 2010-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 2013-02-01
    • 1970-01-01
    相关资源
    最近更新 更多