From: Curious Person Date: 2003-01-29T01:41:41+09:00 Subject: FileTest.size? vs du -b I've noticed something curious. I was throwing together a small script when I noticed that FileTest.size? give a defferent byte size than du -b on the same file. Here's the source: require 'find' def tree_size( file ) result = 0 Find.find (file) do |x| r = FileTest.size?( x ) puts "#{r}\t#{x}" result += r end result end puts File.size( ARGV[0] ) puts tree_size( ARGV[0] ) And here's the output I get: $ ruby ~/text.rb test_dir/ 4096 4096 test_dir/ 5805035 test_dir//file 4 of 4.foo 7388160 test_dir//file 3 of 4.foo 7444001 test_dir//file 2 of 4.foo 7448001 test_dir//file 1 of 4.foo 28089293 Out of curiousity, I compared it to what du would return: $ du -sbc test_dir: 7462912 test_dir/file 1 of 4.foo 7458816 test_dir/file 2 of 4.foo 7401472 test_dir/file 3 of 4.foo 5820416 test_dir/file 4 of 4.foo 28143616 total Er... something doesn't add up. BTW, when I verify the filesizes with ls - al, it matches what FileTest.size returns. Does anyone know what's going on here? Is du inaccurate? Have a Nice Day, -Curious.