block size and du output

i wrote this code to figure if two identical directories on different devices one on a partition and one on a loop had the same total size for -size +0 file only in recrusive tree form.:
awk '$1 ~ /^-/{total=i;i<=NR;i+=$5;print $0}END{print total}'
file1.... .
the output of du -hb was slightly different, but the total of files was the same.. so I tried to figure out the total of the bytes in blocks (?).. (correct me if I am wrong!).
i used bc and took the size of the number of blocks the file added up to which was 21 and multiplied it by (512*512) and devided by 2 what is this output? it looks similiar to the number I got through du but with a couple of digits on the end! is this the size in byts? two byt words? or am i supposed to devide by 8..
{quite confused) moxxx68...

Hmm... this confusion is contagious - i'm not too sure I follow you at all! :wink:

I assume from your previous posts you're still using Linux (and therefore GNU ls). I also will assume that you're trying to display file sizes in 512 byte blocks? If so, you don't need to do any calculation - if you run

ls -Rls --block-size=512

you'll get a total block count at the top of each directories' listing - with each files size in 512-byte blocks in the first column of output, e.g.

$ ls -Rls --block-size=512
.:
total 16
  12 -rw-r--r--    1 zb foogroup     5265 Jan  2 22:34 index.html
   4 -rw-r--r--    1 zb foogroup     2043 Jan 10 14:52 submit_contact.php

So, armed with this, it's fairly easy to grep out the "total"s, and if desired, gain a total block count for the entire tree....

ls -Rls --block-size=512 | grep "^total" | awk 'BEGIN{c=0} {c+=$2} END{print c}'

Cheers
ZB

cheers!
thanx for clueing me in..
moxxx68