#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Ls -s and ls -l returns different file size


    I found an weird thing when i browse through my files with ls -sh option.
    Code:
    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)
    The size returned by -s option and -l option are different.
    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?

    Thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,484
    Rep Power
    1752
    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

IMN logo majestic logo threadwatch logo seochat tools logo