[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Filesize in *du* is inconsistent with *ls -l*
From: |
Bob Proulx |
Subject: |
Re: Filesize in *du* is inconsistent with *ls -l* |
Date: |
Sun, 24 Jun 2001 17:34:31 -0600 |
> In du v4.1 I get filesizes that differ substantialy from those calculated
> by ls -l.
> Is that a bug or a feature ... ?
Neither. One is apples and the other is oranges. You can't compare
apples to oranges.
In one du man page:
du - summarize disk usage
[...]
Summarize disk usage of each FILE, recursively for direcĀ
tories.
Another man page from HP-UX listing the AT&T System V docs which I
think explains a little more:
The du command gives the number of 512-byte blocks allocated for all
files and (recursively) directories within each directory and file
specified by the name operands. The block count includes the indirect
blocks of the file. A file with two or more links is counted only
once.
The 'ls -l' man page:
-l (ell) List in long format, giving mode, number of links,
owner, group, size in bytes, and time of last modification
The size of the file is not the same as the number of 512 byte blocks
of disk space. Filesystems allocate space to files in blocks of fixed
sizes. Therefore a one byte file will get the minimum disk fragment
that can be allocated, or usually 512 bytes, one full disk block.
Your disk usage is 1 512 byte block even though your file size is only
1 byte. A 513 byte file would use 2 512 byte blocks, etc.
Bob