Find the total size of all directories that are owned by a particular User

Hi All,

I am writing a script in which i need find the total size of all the directories that are present in a directory which are owned by a particular user.

I will explain in details
i have a dir DIR1 in which i have 5 dir's DIRA DIRB DIRC DIRD DIRE.
DIRA DIRC DIRE are owned by "eswar" i need to find total size of all the three directories.

Thank you all,
Firestar.

Part of the answer: du -s DIRA DIRC DIRE | awk '{ T+=$1; } END { print T/2, "KB" }'

What is your system? What is your shell?

Hi firestar,

Please try with:

owner=$(ls -l | awk '$1~/^d/ && $3~/eswar/{print $8}')
for i in $owner;
do du -sh $i;
done

Regards