Operating System - HP-UX
1756254 Members
2933 Online
108843 Solutions
New Discussion юеВ

Differents Directory size and files size.

 
SOLVED
Go to solution
ckchai
Frequent Advisor

Differents Directory size and files size.

Hi,

When I "cd /tmp" and do a "ls -l" it show me there is a directory call "Backup" when I look at the size, it is 96. Is this 96 mean 96kb?

Then when I go into the "/tmp/backup" and do a "ls -l", it has only 1 file and the size is 51200. It is 51kb.

why the "ls -l" at /tmp show "Backup" directory is 96? and When go in the actual filesize is 51200?

4 REPLIES 4
Tom Ward_1
Honored Contributor

Re: Differents Directory size and files size.

Hello,

You are seeing the size of the directory entry when you look at /tmp/Backup. That size grows based on the number of files in the directory, not the size of the files in the directory.

I you run a loop and touch a bunch of files in /tmp/Backup the size of /tmp/Backup will grow, but the files will all be zero bytes.

HTH,
Tom
Arunvijai_4
Honored Contributor

Re: Differents Directory size and files size.

Both are different.. When you look at a directory, it is just a size of that *directory*.. When you look at a file size, you will get only *the size of that file*.. Directories are special files under Unix.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"

Re: Differents Directory size and files size.

If you want to see the size of the directory in Kilobytes, do the following:

du -sk /tmp/backup

Please remember to assign points. Hope this helps.

Regards,
Steve
Devender Khatana
Honored Contributor
Solution

Re: Differents Directory size and files size.

Hi,

The size of directory has nothing to do with the size of files in the directory. It is allthough linked to the no. of files in directory. As the no. of files grow in a directory, the directory size grows. But it is not other way round, the size of directory will never reduce and will remain at its max. value ever reached.

For ex. you create a directory and then created some 100 files in it of zero bytes, the directory size will increase and will remain same even if you delete all of those 100 files in that directory.

HTH,
Devender
Impossible itself mentions "I m possible"