NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ls(1) displays wrong file sizes



jgw%freeshell.org@localhost writes:

>Noticed this the other day; if I run 'du -h <random dir>' and compare
>the files sizes to those reported by 'ls -sh1' they don't match. For
>example:

># ls -sh1 PROJECTS/LISP/code/*.lsp
>4.2K PROJECTS/LISP/code/fsvm.lsp
>205B PROJECTS/LISP/code/hello.lsp
>1.7K PROJECTS/LISP/code/recursion.lsp
>1.1K PROJECTS/LISP/code/test.lsp
>4.5K PROJECTS/LISP/code/tictactoe

ls -s would report allocated blocks, i.e. disk usage.

ls -sh is misleading, since it obviously reports file sizes,
not disk usage. I'm not sure if that is correct.

># du -h PROJECTS/LISP/code/*.lsp
>6.0K    PROJECTS/LISP/code/fsvm.lsp
>2.0K    PROJECTS/LISP/code/hello.lsp
>2.0K    PROJECTS/LISP/code/recursion.lsp
>2.0K    PROJECTS/LISP/code/test.lsp
>6.0K    PROJECTS/LISP/code/tictactoe.lsp

du reports disk usage.

You see that your files are allocated in blocks of 2048 bytes.

>bsize 16384 shift 14  mask  0xffffc000
>fsize 2048  shift 11  mask  0xfffff800
       ^^^^

There it is.

-- 
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."


Home | Main Index | Thread Index | Old Index