5

I have a file for which du -b filename gives 67108864 as the answer (which is supposed to be in bytes), while du filename gives 65604 (which is supposed to be in kilobytes).
However, it should return 67108864/1024 = 65536 as the answer.

I looked at the man entry for du, but couldn't find the answer.
What am I missing?

I'm running Ubuntu version 12.04 on a 64 bit machine.

piedpiper
  • 1,222
  • 3
  • 14
  • 27

1 Answers1

4

-b is not just bytes:

  -b, --bytes           equivalent to `--apparent-size --block-size=1'
  --apparent-size   print apparent sizes, rather than disk usage; although
                      the apparent size is usually smaller, it may be
                      larger due to holes in (`sparse') files, internal
                      fragmentation, indirect blocks, and the like
Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • Thanks so much. Therefore logically, I hope it is perfectly fine to treat it as a file with 67108864 bytes, and no more? – piedpiper Apr 16 '14 at 12:20
  • I suppose that depends on what you're doing with it. If you're calculating how big of a hard drive you need, you'd better use `65604*1024`. If you want to know how many bytes you can read from the file, that would be `67108864` – Dark Falcon Apr 16 '14 at 12:25
  • Yes, the latter. Thanks again. – piedpiper Apr 16 '14 at 13:30