From: tester on
Hi Gurus,
I need to have ouput of list of all the directories and sub-dir in a
folder with total no. of dirs.

find . -type d -exec wc -l ls {} \;

Any help is greatly appreciated.
Regards

From: Uli Wachowitz on
On 2006-06-20, tester <bshah(a)citadon.com> wrote:
> folder with total no. of dirs.

> find . -type d -exec wc -l ls {} \;

almost ;-)

> find . -type d | wc -l

Uli

--
Tashi Delek!
Wishing you the auspicious blessings of Buddha nature, shining and
resplendent, complete fulfillment in the highest happiness!
From: GROG! on
On 06-20 14:14 CDT, tester wrote:
>Hi Gurus, I need to have ouput of list of all the directories and
>sub-dir in a folder with total no. of dirs.
>
>find . -type d -exec wc -l ls {} \;

Assuming you need to have a list of all the directories _as well as_
the total, then (all in one line in case this wraps):

$ find . -type d | (typeset -i I=0; while read L; do I=$((I+1)); echo
$L; done; echo Total $I dirs)

This also assumes you're using a modern bourne shell that interprets
the addition properly (ksh, bash, etc)

--
GROG! \|||/ "My life is a soap opera, but who has the
thks -(@ @)- rights?" -- MadameX
/--ooO-(_)-Ooo--\
EMAIL: uber [dot] grog [at] gmail [dot] com
From: Stephane CHAZELAS on
2006-06-20, 12:14(-07), tester:
> Hi Gurus,
> I need to have ouput of list of all the directories and sub-dir in a
> folder with total no. of dirs.
>
> find . -type d -exec wc -l ls {} \;
[...]

Assumming file paths don't contain newline characters:

find . -depth -type d -print | awk -F/ '
{
l = ""
for (i = 1; i < NF; i++) {
l = l "/" $i
n[l]++
}
}
{
print "there are/is " n["/"$0]+0 " dir(s) under " $0
}'


--
St?phane
From: puzzlecracker on

Stephane CHAZELAS wrote:
> 2006-06-20, 12:14(-07), tester:
> > Hi Gurus,
> > I need to have ouput of list of all the directories and sub-dir in a
> > folder with total no. of dirs.
> >
> > find . -type d -exec wc -l ls {} \;
> [...]
>
> Assumming file paths don't contain newline characters:
>
> find . -depth -type d -print | awk -F/ '
> {
> l = ""
> for (i = 1; i < NF; i++) {
> l = l "/" $i
> n[l]++
> }
> }
> {
> print "there are/is " n["/"$0]+0 " dir(s) under " $0
> }'
>
>
> --
> Stéphane

Why make things complicated: just use find . -type d | wc -l as
suggested above... other posts adds unnecessary complexity.... or am I
missing something?

 |  Next  |  Last
Pages: 1 2
Prev: grep exact PID
Next: getopt arguments