need help du -sk


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

If i'm not asking too much then can u help me with a similar cmd to find total size of all target folders as there are hundreds of target folders present.

Now, I am copying the o/p in a excel sheet to find the sum. It would be much better to find the total in one cmd.

Thanks again.
# 9  
Old 11-21-2006
I'm sorry, but I'm afraid I do not understand what you want...
# 10  
Old 11-21-2006
Hi grial

I need to find total size of all 'target' folders (not individually) as there are hundreds of 'target' folders present in the specified path.

Thanks again.
# 11  
Old 11-21-2006
We've already told you:
Code:
find . -type d -name kk -exec du -sk {} \; | awk '{count+=$1; print}END {print "The count is ",count}'

The last line of the command output is the total in kbytes.

Last edited by grial; 11-21-2006 at 08:06 AM..
# 12  
Old 11-21-2006
Hi grial

I just ran the cmd pasted below that u specified but it did not give me total in kb. Please check the o/p.

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

(<moinul>/</home/moinul/21nov06>$)int "The count is ",count}' <
3 ./1/target
3 ./2/target
0 ./3/target
0 ./4/target
3 ./5/target
The count is 9
(<moinul>/</home/moinul/21nov06>$)
# 13  
Old 11-21-2006
Quote:
Originally Posted by mhbd
3 ./1/target
3 ./2/target
0 ./3/target
0 ./4/target
3 ./5/target
The count is 9
It's correct, 9Kb (3+3+0+0+3):

find . -type d -name kk -exec du -sk {} \;
searches for directories called "kk" and executes one "du -sk" for each.
Its output is passed to:
awk '{count+=$1; print}END {print "The count is ",count}'
This command shows you each line while it summs each "du" value to finally display the result.
What's wrong?
# 14  
Old 11-21-2006
Sorry grial, you are right, its correct. I was confused with the word count.

Many thanks.
 
Login or Register to Ask a Question

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