Skip to content

du -b behavior doesn't match GNU du #10661

@spholz

Description

@spholz

For GNU coreutils, the order of arguments matters in du:

$ du -m -sb Base
23507402	Base
$ du -sb -m Base
23	Base

-b means both --apparent-size and --block-size=1. If -b is before -m (--block-size=1M), the size is printed in megabytes.

uutils du ignores the order and always prints the size in bytes:

$ ~/repos/uutils-coreutils/target/debug/coreutils du -m -sb Base/
23507402	Base/
$ ~/repos/uutils-coreutils/target/debug/coreutils du -sb -m Base/
23507402	Base/

SerenityOS currently needs a workaround for this (see SerenityOS/serenity#26120 and SerenityOS/serenity#26121).
We can't use --apparent-size everywhere since BusyBox only supports short arguments, so only -b, which is described as:
-b Apparent size (including holes)
For BusyBox this argument doesn't even mean --block-size=1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions