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

Leroy Tennison leroy_tennison at prodigy.net
Sat Jan 21 04:37:48 CST 2006


Chris Cox wrote:

>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
>
>
>
>_______________________________________________
>https://ntlug.org/mailman/listinfo/discuss
>
>  
>
Well, that's why I'm confused.  I ran it literally just as I received it 
(didn't replace $dir with anything, just used it as-is) and it worked. 
 That's when I went looking for either 'dir' or 'DIR' in the environment 
and checked 'man find' to see if $dir had special meaning to the 
program.  Came up empty.  Then I tried Google and Yahoo only to find 
that they treat '$' special somehow and return way too many hits where 
$dir isn't even in the 'hit'.  At that point I turned to the group, 
still no answer to this point.  The speculation I'm toying with now is 
whether a dynamic variable is being created for the duration of 'find' 
and destroyed at program termination.  Even if this is true (maybe a big 
if) I don't have any idea how to confirm or deny it.





More information about the Discuss mailing list