/*******************************************************************/ /* my_du - Utility program. */ /* */ /* My_du calls "du" to find disk-space used down directory */ /* branches, but lets you limit the number of levels to resolve. */ /* Default shows only 3 levels. */ /* It only prints amount of space once, unlike 'du' which shows */ /* progressive roll-ups. */ /* It lets you show branchs only larger than a given KB amount. */ /* Use as: */ /* my_du -levels 2 directoryxxx */ /* my_du -screen 1000 -levels 3 directoryxxx */ /* */ /* Explanation: The raw-std 'du' provided on conventional systems */ /* produces a difficult to use output. Specifically, 'du' */ /* has no way of limiting the number of levels of directory */ /* branches that it shows. For large directory systems, it */ /* would be useful to just see where the major branches are, */ /* but 'du' spews long lists showing every leaf branch. */ /* Also, 'du' accounts for the same disk space multiple times,*/ /* adding difficulty to understanding where disk space really */ /* is. For example, suppose directories such as: */ /* A ---- 10 KB */ /* |__ B 20 KB */ /* |__ C 30 KB */ /* The total disk-space = 10+20+30 = 60 KB. */ /* However, 'du' would display: */ /* 20 B */ /* 30 C */ /* 60 A */ /* This might imply a total space of 10+30+60 = 100 KB, but */ /* is incorrect because the space in the lower directories */ /* was counted twice. Although this appears interpretable in */ /* this simple example, it creates a totally intractable */ /* problem for large multi-level directories. */ /* Additionally, the units of 'du' are cryptic and not shown, */ /* adding more trouble to interpretting the output. */ /* (Specifically, default units = 512 Byte blocks, whereas */ /* other user tools are in bytes, such as 'ls'.) */ /* */ /* To improve the above features, 'my_du' was created. */ /* 1. Ability to limit directory levels shown */ /* (Though all space under them is counted once and */ /* consolidated at the truncation level.) */ /* 2. Given disk space appears once. */ /* (Each directory shows just the space in that */ /* directory (unless it contains subdirectories that */ /* were not displayed (below truncation level), in */ /* which case shows the consolidated roll-up and is */ /* followed by "...").) */ /* (i.e. A directory name followed by "..." means: */ /* this is the space is in that directory, plus */ /* branches it contained below it which were not */ /* shown due to requested truncation.) */ /* 3. Units are clearly displayed in Kilo-Bytes. */ /* 4. Can 'screen-away' insignificant directories to show */ /* only those larger than user-defined size. */ /* (i.e. Show me just the big branches containing */ /* more than xx-MB.) */ /* */ /* The output is much simpler, more brief, and easily */ /* interpreted. It is useful for understanding where within */ /* large directory structures disk space is allocated, or has */ /* grown. Especially useful when trying to cleanup and */ /* save space. */ /* */ /* Output appears in two columns as: */ /* */ /* Space (KB) Directory */ /* ---------- ------------------------ */ /* */ /*******************************************************************/