Sort du -h output by size

Published at 24 Jun 2025

The command du is useful to explore the folder content sizes, but the results are sorted by name instead of size.

To sort them by size, we must pipe it to the sort command:

du -hs * | sort -h

When run this command, it will first get the folder content sizes and then sort them, so it might take a while to show some output.