find misreports file size when using %b, %k

Jeremy Hetzler jeremyhetzler@earthlink.net
Fri Aug 30 19:11:00 GMT 2002


The "find -printf" escapes %b and %k should return filesize in 512-byte 
blocks and in 1k blocks, respectively. Instead, %b returns size in 1k 
blocks, and %k returns size in 2k blocks; i.e. the values are half those 
expected. %s, filesize in bytes, works correctly. Is this standard 
behavior, or Patches Gratefully Accepted? (Win2k, NTFS, Cygwin ver 1.3.12-4)

$ dd if=/dev/null of=foo bs=1024 count=0 seek=1000
0+0 records in
0+0 records out

$ ls -la foo
-rw-r--r--    1 steveb   None      1024000 Aug 30 22:03 foo

$ du -sk foo
1000    foo

$ find -name "foo" -printf "%s %b %k"
1024000 1000 500

$ find --version
GNU find version 4.1.7

>From find.info:

Size Directives
...............

`%k'
     File's size in 1K blocks (rounded up).

`%b'
     File's size in 512-byte blocks (rounded up).

`%s'
     File's size in bytes.


More information about the Cygwin mailing list