DU and LS discrepancies
Posted: Fri Aug 11, 2006 9:14 pm
I'm writing a script for my job to measure out how large IMAP mailboxes are, and I've run across what I think is a predicament:
The directory I'm measuring (as a test) is as follows:
I've noticed that if I add up the above file sizes (either manually or through ls -l), the total comes to 67966. However, if I du -s the same directory, it comes up with 90112. What the hay?
So, I read up a bit more on du. Apparently, it measures in blocks, not actual file sizes. Is this correct? If so, I would assume (against my better judgement) that this discrepancy would increase leaps and bounds as the directories get larger. Would there be any way to get du to report the filesize instead?
Thanks in advance,
Jeremy
The directory I'm measuring (as a test) is as follows:
Code: Select all
root@server [~/imapdtool/testdir]# ls -l
total 92
drwxr-xr-x 2 root root 4096 Aug 11 15:04 ./
drwxr-xr-x 3 root root 4096 Aug 10 21:22 ../
-rw-r--r-- 1 root root 121 Aug 11 15:04 error_log
-rw-r--r-- 1 root root 20176 Aug 10 21:22 file1
-rwxr-xr-x 1 root root 91 Aug 10 21:22 file2
-rw-r--r-- 1 root root 6939 Aug 10 21:22 file3
-rw-r--r-- 1 root root 4824 Aug 10 21:22 file4
-rw-r--r-- 1 root root 10434 Aug 10 21:22 file5
-rw-r--r-- 1 root root 6742 Aug 10 21:22 file6
-rwxr-xr-x 1 root root 471 Aug 10 21:22 file7*
-rwxr-xr-x 1 root root 91 Aug 10 21:22 file8*
-rwxrwxrwx 1 root root 9885 Aug 10 21:22 file9*So, I read up a bit more on du. Apparently, it measures in blocks, not actual file sizes. Is this correct? If so, I would assume (against my better judgement) that this discrepancy would increase leaps and bounds as the directories get larger. Would there be any way to get du to report the filesize instead?
Thanks in advance,
Jeremy