need help du -sk


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers need help du -sk
# 15  
Old 11-21-2006
Don't worry Smilie
You can just change it into:
Code:
find . -type d -name kk -exec du -sk {} \; | awk '{count+=$1; print}END {print "Total:  ",count,"kb"}'

# 16  
Old 11-22-2006
Quote:
Originally Posted by grial
Don't worry Smilie
You can just change it into:
Code:
find . -type d -name kk -exec du -sk {} \; | awk '{count+=$1; print}END {print "Total:  ",count,"kb"}'

grial /All

I know the first will do the recrusive listing and search and an you please explain tha AWK part.........

Thanks in advance,
Arun.
# 17  
Old 11-22-2006
Sure!
Code:
... awk '{count+=$1; print}END {print "Total:  ",count,"kb"}'

I'm not an awk expert but here we go!
"count" is where the size is going to be contained.
In the first {}, for each line (result of du), count will increment by adding the first field value, represented by $1 (by default fields are separated by spaces and/or tabs). In this case, the first field is the size of the folder. And print the whole line.
Finally, in the second {}, the result is shown.
Regards.
# 18  
Old 11-22-2006
Hello grial

The cmd was giving desired o/p just fine but in one case it gave the following o/p due to large size of the folders

Total size 6.83465e+07 KB

Now how do i change the count variable type to double or equivallent to store large value.

Thanks again
# 19  
Old 11-22-2006
man awk Smilie (I'm sorry but I do not know)
Anyway, what's the problem?
Just multiply 6.83465 x 10000000 Smilie
# 20  
Old 11-22-2006
ok no problem this will do too Smilie
# 21  
Old 11-23-2006
Quote:
Originally Posted by grial
Sure!
Code:
... awk '{count+=$1; print}END {print "Total:  ",count,"kb"}'

I'm not an awk expert but here we go!
"count" is where the size is going to be contained.
In the first {}, for each line (result of du), count will increment by adding the first field value, represented by $1 (by default fields are separated by spaces and/or tabs). In this case, the first field is the size of the folder. And print the whole line.
Finally, in the second {}, the result is shown.
Regards.

Grial thanks for your explanation and very great of you .. Please let me know why we are using print here "{count+=$1; print}" . please let me know the use of print here if we didnt use print here is it right ?? .Let me know ,also with that i am new to AWK...

Thanks in advance,
Arun kumar
 
Login or Register to Ask a Question

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