[Gllug] counting subdirectories

Jack Bertram jack at jbertram.net
Tue Oct 14 14:49:27 UTC 2003


* stanley <stanley12 at blueyonder.co.uk> [031014 15:40]:
> Hopefully this will be an easy one for most,
> 	For my university coursework I have been asked to create an alias that will
> count and display the number of subdirectories in one directory, and so far
> the best I have managed is
> 
> alias dc="ls -1aF | grep "/" | wc -l"
> 
> this work but also includes the parent and root directories in the count.
> Anyone with any tips.

I would recommend checking out the utility "find", and in particular noting
the options

-type
-mindepth
-maxdepth

jack

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list