[Gllug] counting subdirectories

Matthew King matthew.king at monnsta.net
Thu Oct 16 15:23:31 UTC 2003


On Tue, 2003-10-14 at 16:32, Tethys wrote:
> "stanley" writes:
> 
> >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.
> 
> So just remove them:
> 
> 	alias dircount="expr $(ls -1aF | grep / | wc -l) - 2"
> [...]
> 	leto:~% dircount /lib
> 	8

Wouldn't the -A switch to ls make things a whole lot easier?

       -a, --all
              do not hide entries starting with .

       -A, --almost-all
              do not list implied . and ..

Assuming that's not yet another GNU extension.

Matthew

-- 
GIT/CM d+(-) s++:- a-->? C++++ UL++++$ P+++>++++ L++>++++ E>++ W--$ N
o? K++ w--- O-- M V? PS+>+++ PE-- Y+>++ PGP++@ t+ 5- X- R tv b+++>++++
DI++ D++ G e(*) h!>- r--- y->+++



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




More information about the GLLUG mailing list