Sorting human readable file sizes
Use GNU coreutils >= 7.5:
du -hs * | sort -h
(Taken from this serverfault question)
Man page
Edit: You can check your versions using du --version
and sort --version
if you are using the GNU versions. If you're using homebrew you may need to use gdu
and gsort
.
Afaik, there's no standard command to do this.
There are various workarounds, which were discussed when the same question was asked over at Stack Overflow: How can I sort du -h output by size
If you are just worried about files larger than 1MB, as it seems you are, you can use this command to sort them and use awk to convert the size to MB:
du -s * | sort -n | awk '{print int($1 / 1024)"M\t"$2}'
Again, this rounds the sizes to the nearest MB. You can modify it converting to the unit of your choice.