July 31st, 2012, 04:32 AM
Ls -s and ls -l returns different file size
I found an weird thing when i browse through my files with ls -sh option.
The size returned by -s option and -l option are different.
512M -rw-rw---- 1 user user 20K Jul 3 23:00 2012 /path/a.MYI .....(1)
512M -rw-rw---- 1 user user 19K Jul 3 23:00 2012 /path/b.MYI .....(2)
512M -rw-rw---- 1 user user 16K Jul 3 23:00 2012 /path/c.MYI .....(3)
512M -rw-rw---- 1 user user 5.0K Jul 9 15:30 2012 /path/d.MYI .....(4)
4.0K -rw-rw---- 1 user user 4.0K Jul 3 23:00 2012 /path/e.MYI .....(5)
I understand that -s prints the allocated size in blocks, but i expect smaller figure in this case.
But the result shows 512M block size for a file of 20K.
Hmm.. can i assume that something is wrong?
Or anyone can explain this situation?
July 31st, 2012, 06:06 AM
The -h option is returning al the sizes in 'human readable' form, which look to be 'monkeying' with the blocksize output - a quick poll of a directory shows, for me, the block values (those given with the -s) are multiplied by 1024 as Linux is assuming a base unit of KB. My suggestion would be do not mix -s and -h.
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc