[olug] Speaking at Infotec April 14-15, 2009

Obi-Wan obiwan at jedi.com
Tue Mar 31 19:44:39 UTC 2009


> Had a situation the other day where a partition was filling up. I wanted 
> to know which directories in that partition where the biggest offenders. 
> This little one-liner gave me a list of all (top-level) directories in 
> that partition, sorted by size, highest to lowest:
> 
> # ls -1 | egrep -v "\.|\.\." | while read line; do if [ -d "${line}" ]; then result=`du "$line" -c | grep -i total| awk -F" " '{print $1}'`; echo "$result: $line"; fi; done | sort -rn
> 
> Like most of my scripts, I'm sure there is a much more efficient way to do 
> it, but this worked for me.

How about:

# du -ksc .??* * | sort -rn

Or, if you only want directories displayed:

# find . -maxdepth 1 -type d | xargs du -ksc | sort -rn

-- 
Ben "Obi-Wan" Hollingsworth                             obiwan at jedi.com
   The stuff of earth competes for the allegiance I owe only to the
     Giver of all good things, so if I stand, let me stand on the
       promise that You will pull me through.  -- Rich Mullins



More information about the OLUG mailing list