Linux - disk usage (du) human readable and sorted by size(earthinfo.org)
earthinfo.org
Linux - disk usage (du) human readable and sorted by size
http://www.earthinfo.org/linux-disk-usage-sorted-by-size-and-human-readable/
This is quick tip to fix a problem that has always bugged me - When showing disk usage in a human readable form (KB, MB, GB) for each subdirectory using “du -sh *”, how can you properly sort it into size order?
2 comments
This is a good argument for seperating content from presentation, in the same method an object shell does. For every workaround, there's still the underlying issue needing workarounds in the first place.
this is my solution, comments?
du -s * 2>/dev/null | sort -n | cut -f2 | xargs du -sh 2>/dev/null
du -s * 2>/dev/null | sort -n | cut -f2 | xargs du -sh 2>/dev/null