shell scripting help

what I’m trying to achieve is the following…

we get alerted when root filesystems fill up to >90%
I’d like a script that reports the following information:-
a “du -ks” for every dir mounted under the / dir NOT including those dir’s which are mounted on their own filesystems but are still mounted under /

eg: if I do a “du -ks *” from / I get the size of each dir.
what I’d like is for this report to ignore all those dirs which are mounted on their own (soft)partition.

I can get a list of dir’s using “ls -lp / | grep / | awk ‘{print $9}’”
I can get a list of seperately mounted filesystems using “df -k | awk ‘{print $6}’”

what I can’t do is get my head around how I to do a “du -ks” on each dir that appears in the output of the first command but doesn’t appear in the output of the 2nd.

I hope I made that clear :wink:

any help much appreciated - I’m lost in world of foreach and while loops atm :smiley:

I “think” this does what you want

for file in `ls -d1 /*`
        fs=`df -k $file|tail -1|awk ' { print $NF } ' `
        if [ $fs = "/" ]
                du -sk $file
 done | sort -n

cool, I’ll give it a wirl tomorrow! :slight_smile:

thanks :thumbsup:

very nice! does everything I asked for :thumbsup:

thanks loads mate :slight_smile:

No worries