[NTLUG:Discuss] Re: Is there a command line utility which will report directory statistics?

Chris Cox cjcox at acm.org
Fri Jan 20 00:55:12 CST 2006


Leroy Tennison wrote:
> Graham Wilson wrote:
> 
>> On Thu, Jan 19, 2006 at 06:20:47AM -0600, Leroy Tennison wrote:
>>  
>>
>>> Such things as number of files,
>>>   
>>
>> find $dir -type f | wc -l
>>
>>  
>>
>>> number of subdirectories,
>>>   
>>
>> find $dir -type d | wc -l
>>
>>  
>>
>>> size?   
>>
>> du
>>
>>  
>>
> Thank you, that's exactly what I needed and would have never found by
> searching.  A couple of questions:
> 
> Where is $dir documented?  I thought it was a reference to a BASH shell
> variable but couldn't find either 'dir' or 'DIR' using "set | less".
> Googling and trying Yahoo proved futile because both interpret the $
> somehow.
> 
> Second, I take it that 'du' reports only in blocks rather than actual
> aggregates of sizes even if the '-b' switch is used, correct?  The
> reason I ask is that I'm looking for an equivalent of what the Evil
> Empire does when it calculates directory sizes.
> 
> Again, thanks for the help.

$dir is a variable... replace that with the directory to
recurse through.

Could be the current directory (you can use . for that)...

find . -type d | wc -l






More information about the Discuss mailing list