need help du -sk


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers need help du -sk
# 1  
Old 11-21-2006
need help du -sk

Dear All

I need to find du -sk result (size of the folder in KB) of a particular
sub-folder namely 'target' which is available in many sub-folders under the
follwing path of /home/moinul/21nov06

(<moinul>/</home/moinul/21nov06>$)ll
total 0
drwxrwxrwx 6 moinul systemchk 96 Nov 21 11:53 1
drwxrwxrwx 6 moinul systemchk 96 Nov 21 11:54 2
drwxrwxrwx 6 moinul systemchk 96 Nov 21 11:56 3
drwxrwxrwx 6 moinul systemchk 96 Nov 21 11:56 4
drwxrwxrwx 6 moinul systemchk 96 Nov 21 11:56 5


I have 5 folders.

(<moinul>/</home/moinul/21nov06>$)lsf *

1:
m1/ m2/ m3/ target/

2:
target/ u1/ u2/ u3/

3:
j1/ j2/ j3/ target/

4:
p1/ p2/ p3/ target/

5:
c1/ c2/ c3/ target/


There are many sub-folders under path /home/moinul/21nov06 including target folders

(<moinul>/</home/moinul/21nov06>$)cd 1
(<moinul>/</home/moinul/21nov06/1>$)cd target
(<moinul>/</home/moinul/21nov06/1/target>$)du -sk
3 .
(<moinul>/</home/moinul/21nov06/1/target>$)


Can anyone help me to find total size of all the target folders available
under path /home/moinul/21nov06

Thanks in advance.
# 2  
Old 11-21-2006
Can you try this one ?.

du -a | grep -i '/target/' | awk '{count+=$1}END {print "The count is ",count}' .

Please do let me know if this works
# 3  
Old 11-21-2006
Using dhanamurthy's awk piece of code:
Code:
find . -type d -name target -exec du -sk {} \; | awk '{count+=$1}END {print "The count is ",count}'

This way, olnly desired directory space ("target" directories in this case) is estimated.
Regards.
# 4  
Old 11-21-2006
Hi dhanamurthy

Following o/p appeared:

(<moinul>/</home/moinul/21nov06>$)}END {print "The count is ",count}' <
The count is 18
(<moinul>/</home/moinul/21nov06>$)

Can u pls explain why count is 18? Also I need size of the target folders in KB.

Thank you for the replies.
# 5  
Old 11-21-2006
Hi grial

executed the cmd u provided and it gave me the correct count which is 9. But I need the size of the target folders.

(<moinul>/</home/moinul/21nov06>$)ND {print "The count is ",count}' <
The count is 9
(<moinul>/</home/moinul/21nov06>$)

Thanks for your reply.
# 6  
Old 11-21-2006
Code:
find . -type d -name kk -exec du -sk {} \;

Will give you the count per directory.

Code:
find . -type d -name kk -exec du -sk {} \; | tee -a | awk '{count+=$1; print}END {print "The count is ",count}'

Will give you the the same, plus the sum.

Last edited by grial; 11-21-2006 at 05:21 AM..
# 7  
Old 11-21-2006
Thanks grial

This is exactly what i needed. cheers!
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question