EZ Linux Admin random header image

Sort and find a directory size

September 2nd, 2009 by EZ linux · 1 Comment

The easiest and fastest way is:
du -sh *
But if you want to search recursively and display in order you need this one:
du -h --max-depth=1 /home/ | sort -n -r
And if you want even more depth try:
du -s ./* | sort -n| cut -f 2-|xargs -i du -sh {}
I recommend trying all three with a fairly small folder to see which one you like best, the progressively (as they go down) require more cpu and time to run.
Also if you want just to find a directory size try this:
du -h /usr/

Tags: Linux Commands

1 response so far ↓

  • 1 sort and find a directory size | Linux Certification // Dec 22, 2009 at 6:20 am

    [...] by lpilinuxblog on Dec.22, 2009, under About LPI “The easiest and fastest way is: du -sh * But if you want to search recursively and display in order you need this one: du -h –max-depth=1 /home/ | sort -n -r And if you want even more depth try: du -s ./* | sort -n| cut -f 2-|xargs -i du -sh {} I recommend trying all three with a fairly small folder to see which one you like best, the progressively (as they go down) require more cpu and time to run. Also if you want just to find a directory size try this: du -h /usr/”ezlinuxadmin.com [...]

Leave a Comment