ls -l output difference between files and directories?

1

I looked at IBM's site and read the definition for ls -l, but could not find an answer to my question.

When issuing an ls -l command on AIX, what is the explanation for the different 'file size' values between a directory and a file in the listed output?

Directory =>             drwxr-xr-x    3 owner group     1601536 Sep 27 10:24 directory/

Tar File of Directory => -rw-r--r--    1 owner group  9554513920 Oct 09 10:29 directory.tar

The actual size of the directory and file is the same, at about 9 GB.

Why does the directory show 1601536 (1.6 MB?) and the file show as 9554513920 ( 9.5 GB)?

I know its not a file count because I get this for a file count -

$ cd directory

$ ls | wc -l

20708

Thanks for any answers.

hacket

Posted 2013-10-09T15:45:55.603

Reputation: 111

Why all the votes to close this question? Its a good question for someone who is new to Unix, and I have spent a good deal of time searching for the answer. If it's so obvious, then post the answer. – None – 2013-10-09T16:30:30.643

Answers

3

In UNIX the size of the directory reported by ls is not the size of all files under it. It is the size of the "directory" as a "file" that contains a list of entries under it. This hails back to the original UNIX filesystems structure where a directory was a file with a special bit on that contained a table of inode entries underneath it.

Alexander L. Belikoff

Posted 2013-10-09T15:45:55.603

Reputation: 166

I had a hunch this was it. Thank you for answering. – None – 2013-10-09T17:00:12.340