Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: ls -l command

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141

    ls -l command


    936K -rw-r--r-- 1 root root 33M Jan 10 13:12 /conf/events.log


    the above listing shows the long listing of the file by the command

    "ls -lsh /conf/events.log"

    Anyone please tell me what is the 33M for? is it filesize?

    since 936K is also the file size, right?

    so why the difference.

    One more thing is that while clearing the file i just truncate it to a zero length file using the open command in C. is that why the problem happens?

  2. #2
    File size in 1024-bytes file block maybe?

  3. #3
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    The first size is from the -s option, and this quote is from the info page on ls:
    This is the amount of disk space used by the file, which is
    usually a bit more than the file's size, but it can be less if the
    file has holes
    The other size is from the -l option and is a byte count on the file. So it would seem that it is a 33mb file that takes up 936kb disk space.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    do u know what exactly is the meaning of

    " the file having holes" ?

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Some filesystems are capable of lazy allocation, which means that if you extend a file's size be means of e.g. the truncate() syscall, blocks won't be allocated for the extended area of the file until they are actually written to.

    A log file seems like an unlikely candidate to have holes, though. I'm unsure what it means in this particular case. There might be some other tricks played by the filesystem. The consensus is that the leftmost number (the one produced by the -s option) is the total amount of space in the disk blocks allocated to the file, not the logical file length, and filesystems sometimes use non-obvious tricks to keep block allocation down.

  7. #6
    Quote Originally Posted by sharonenoch
    One more thing is that while clearing the file i just truncate it to a zero length file using the open command in C. is that why the problem happens?
    FWIW -
    try
    Code:
    > events.log
    # or
    cat /dev/null > events.log
    which uses the same mechanism (truncate) as the fopen() function does in C.

    Any file call to the filesystem has to use open ultimately. You should not see anything special just because you made it from a C call.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •