Saturday, November 21, 2009

Listing the size of directories

By doing ls -l, you won't get the size of directories. It will only be listed as 4.0K, while the files are listed correctly. But even the files are actually not listed correctly if you are currently changing the file, for instance during a download. It will list the final size of the file, not the current file size.

If you instead use the 'du' (disk usage) command, you will get a more correct number, even for directories.
du -sh *
will list all the files and directories in the current folder, with the size it occupies on the disk.

No comments: