file size confusion !!
I came in to this issue while trying to locate empty files ( zero byte). I used find command
Code:
find . -size 0c Code:
find . -size 0c | xargs du -rw------- 1 root root 0 Mar 11 10:50 ./.gconf/apps/%gconf.xml -rw------- 1 root root 0 Apr 6 09:50 ./.gconf/apps/ggv/%gconf.xml -rw------- 1 root root 0 Mar 11 10:51 ./.gconf/apps/panel/objects/%gconf.xml when I copy the %gconf.file, the output file shows the zero size (using du) but original file remains same (4k)....isnt it confusing ? additonal info: uname -a Linux ldsqd.sun 2.6.21 #3 SMP Tue Apr 1 04:19:45 EDT 2008 i686 i686 i386 GNU/Linux cat /etc/redhat-release Red Hat Desktop release 4 (Nahant Update 2) |
The files showing as 4k have probably contained data at one point, even though they are now empty.
Use "tune2fs -l /dev/yourdisk" and you will see that the block-size for the file system on that partition is 4096 bytes, or 4k. So even if you put 1 byte in the file, it takes up 4k on disk. When the file grows from 4096 bytes to 4097, it pushes into the second block, and so takes up 8192 on disk. Hope this explains it for you. |
This is a total shot in the dark but it *could* be a function of file system blocks being allocated because du's intention is to show you the effect on the file system the file is causing... if that makes any sense.
If you add the -b switch to du (find . -size 0c | xargs du -b) do they all show up as 0 now? |
Code:
tune2fs -l /dev/mapper/VolGroup00-LogVol00 and also if I copy the file, then how the output file size becomes zero, it should also say the same thing 4k.... Quote:
|
@jtshaw
Yeah...now it is showing correct output..... but I don't think I understood the concept completely....can you explain a bit the difference ....? Code:
find . -size 0b | xargs du -b Quote:
|
Quote:
|
thank you for the explanation...now I understood, why the different commands showing different output...Now I will try to dig deeper in to the file system knowldege base to get an idea about some of those reasons which are making the du command confuse....Thanks again....
Quote:
|
All times are GMT -5. The time now is 09:30 AM. |