Hi,

I'd like to propose a small addition to du: a --sort=size flag that
automatically sorts output by size (descending) and limits depth to 1.

Motivation

The most common real-world use of du is finding what's consuming disk space
in a directory. The typical workflow is:

du -h --max-depth=1 /home | sort -rh

This requires piping to sort, which breaks --total, loses context when
combined with other flags, and is non-obvious for new users.

Proposed behavior

du -h --sort=size /home

- Implies --max-depth=1
- Sorts output by size, descending
- Compatible with -h, --time, --total
- If entries exceed 10,000, truncates with a message: ... and N smaller
entries omitted

Scope

Implementation would be ~100 LOC in du.c, reusing existing print_size() and
related helpers. I've searched the mailing list archives and Savannah
tracker and found no existing proposal for this.

I considered a short option alias but -s and -S are already taken. Open to
suggestions.

Before writing the patch, I wanted to check if this would be welcome and if
there are any design concerns I should consider.

Thanks,

Daniel

Reply via email to