Search code examples
sortingunixdu

unix command - size of directory with order by size


I use this command:

du -h --max-depth=1 | sort -s

And my result is:

1.1M    ./abcd
1.1M    ./efgh
1.1M    ./xyxabcd
1.2G    ./oleoleole
1.2M    ./tests
196K    ./super-Package
2.0M    ./myjobs-build

However, I want it to be ordered by size like this:

1.2G    ./oleoleole
2.0M    ./myjobs-build
1.2M    ./tests
1.1M    ./abcd
1.1M    ./efgh
1.1M    ./xyxabcd
196K    ./super-Package

Solution

  • You can try du -h --max-depth=1 | sort -hr