DEV Community

Cover image for Sort du -h output by size
Sergio Peris
Sergio Peris

Posted on • Originally published at sertxu.dev

Sort du -h output by size

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
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)