Operating System - HP-UX
1832269 Members
3376 Online
110041 Solutions
New Discussion

Different size for ls -l and du -ks for a file

 
SOLVED
Go to solution
Catherine Forget
Frequent Advisor

Different size for ls -l and du -ks for a file

Hi,
I have 3 files with the same size when I do ls -l, but if I do du -ks the answer is very different with one of them. Any idea why?
I copied the file somewhere else and got a different 'du' for the file.

Any idea? the file was recreated and seems to always give the same size...
Thanks
6 REPLIES 6
Patrick Wallek
Honored Contributor

Re: Different size for ls -l and du -ks for a file

These are sparse files.

The size given by 'ls -l' is the size the file was created as in Oracle.

The size given by 'du' is the amount of data actually in the file.
Steven E. Protter
Exalted Contributor

Re: Different size for ls -l and du -ks for a file

Shalom,

Two diffrent tools, two different ways of calculating used space.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor
Solution

Re: Different size for ls -l and du -ks for a file

Hi Catherine:

The first difference in size is that 'ls' reports characters and 'du -k' reports 1024-character _blocks_. The smallest block size will be that which the underlying filesystem was created with --- the 'bsize' value reported by 'mkfs -m'.

The tip-off that the files are sparse is their inflation when you use 'cp' to copy them. Database files are commonly allocated as sparse ones.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Different size for ls -l and du -ks for a file

"ll -e" should provide the extend info for your sparse files.
Catherine Forget
Frequent Advisor

Re: Different size for ls -l and du -ks for a file

Thanks for the info
Catherine Forget
Frequent Advisor

Re: Different size for ls -l and du -ks for a file

thanks