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

David Walker olug at grax.com
Tue Mar 31 22:01:40 UTC 2009


I generally use "du -shx *", which is easier to read but harder to sort.
Some of my older and smaller drives have mount points several levels
down for one reason or another and the "x" keeps the search restricted
to a single file system.

Obi-Wan wrote:
>> 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
>
>   




More information about the OLUG mailing list