28/02/2009

Spring cleaning: Find big directories

du is a tool listing directory tree sizes. Simple du produces tons of console output, so we reduce the search depth (anything below is summed up anyway), run it through grep to exclude small dirs and pipe it to a file.
du -h --max-depth=2 | grep '^[5-9][0-9]\{2\}M\|[0-9]G' > listfile.txt
  • -h for human: lists sizes in G, M, and K. Important for grep search. Change the max. search depth to your liking.
  • Grep string: searches for 500-999M at the beginning of the line or anything containing a number and 'G', thus anything over 500MB. See this link for grep reg. expressions. "\|" is the grep "or" operator, btw.
  • If you want a graphical tool, try KDirStat (it's also in the openSuSE main repo). It's a bit old, but works well on KDE 3 and 4.

No comments: