Finding the size of a directory was one of the things I could not figure out how to do from the terminal. I recall someone saying that one would require
sed and
gawk to do it. That terrified me...
So here is the simple way to do it.
[rishi@Sunflower ~]$ du -sh /data4.8G /data
[alien@Sunflower ~]$ du -sh .
20M .
However it becomes quite slow if one wants to check the size of something as big as /. This is because the cumulative sum of all the files and folders are actually found during run-time to find the size. The following command took me almost 5 minutes.
[rishi@Sunflower ~]$ sudo du -sh /18G /Doesn't the ext3 filesystem store the sizes of directories somewhere permanently? If not, then how come
df is so fast? The following does not take even a second to execute.
[rishi@Sunflower ~]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/hda2 18G 11G 6.0G 64% //dev/hda1 92M 19M 68M 22% /boot/dev/hda3 6.0G 4.8G 845M 86% /datatmpfs 109M 0 109M 0% /dev/shm/dev/hda7 221M 49M 161M 24% /devel/dev/hda5 2.0G 1.7G 222M 89% /home/dev/hda6 996M 34M 911M 4% /tmpThese are the questions I need to find answer to now...