finding total used space by a user in a directory
Hi there, I am wondering why this syntax is not working as expected.. any help owuld be appreciated, thanks
for foo in `$AWK -F":" '{print $6}' $PASSWD` ; do
#Checking if i have the permission to read these directories
if [ -r $foo ] ; then
if [ "$foo" != "/" ] ; then
#getting username, home directory and User ID
HOME=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $6}'`
USER=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $1}'`
UID=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $3}'`
if [ $UID -gt 500 ] ; then
if [ $UID -lt 60000 ] ; then
HOMESPACE=0
VARSPACE=0
PRJSPACE=0
#Finding the amount of space use in the home for the user
HOMESPACE=`du -h -k -s $HOME | awk '{print $1}'`
#Finding amount of space use in /var
echo "Finding all files owned by $USER in /var...and adding their total space used "
find var/ -user $USER -exec du -k -s -h {} \; | awk '{user[$1]+=$2}; END{ for (i in user) { VARSPACE=expr '$VARSPACE'+ i }'
echo $VARSPACE
fi
fi
fi
fi
done
My problem is that the value of VARSPACE is always 0, it seems that awk cannot change the value of the variable VARSPACE... any idea or solution to do calculate the total use soace by a particular user in the var directory??? thanks
|