Block Size Program

Gerald Combs gerald at ethereal.com
Sat Jul 6 18:35:15 CDT 2002


On Sat, 6 Jul 2002, david nicol wrote:

> DCT Jared Smith wrote:
> 
> > There are 512 bytes to a block. You can do the math in
> > your head after the first coupla times, because 1K is
> > two blocks.
> > 
> > The problem comes in the way that a 12 byte file will
> > appear in Windows as a 1Kb file, because Windows won't
> > measure in less than 1K increments.
> 
> du and df both have command line switches to alter their
> display block sizes, too.

Odd.  On my Linux desktop, the man page for 'ls' states that the '-s' flag
shows sizes in blocks.  Empirical evidence shows that it actually displays
sizes in kilobytes.  du and df default to 1K sizes as well on my system.  
Maybe it has something to do with RMS' position on 512-byte blocks:

    http://gammatron.novarese.net/txt/posix.html

AFAIK, non-GNU versions of ls, du, df, et al default to 512-byte blocks.
They typically have a '-k' which shows sizes in kilobytes.  The GNU
versions go a bit further, and offer a '-m' flag for megabytes and a '-h'
flag which shows sizes in human-readable form, e.g. 740742526 bytes is
shown as '708M'.

I use this last one a lot, since I personally don't care about sizes past
three or four significant digits.  Compare the output of 'df' and 'ls -s'
to 'df -h' and 'ls -sh'.  Which one does your brain parse more easily?

> 
> -- 
> In the commonwealth of Massachusetts, dogs can vote.
> 
> 
> 




More information about the Kclug mailing list