Operating System - HP-UX
1825985 Members
3126 Online
109690 Solutions
New Discussion

Re: counting sub-directories

 
SOLVED
Go to solution
Gord Moore
Frequent Advisor

counting sub-directories

On my 11i system, the automated process gets the error "Too many links" when trying to make a new directory (new log file directory every day, and several at the same time -- stupid application!)

Anyway, searching here I found that PHKL_28185 has removed vx_maxlink as a configurable parameter and set it to 65534. That should be enough, but I need to see how many directory links there are. I tried this but I am not sure I am getting the right number.

ls -R | grep "./" | wc -l

I am counting the number of times ./ appears which seems to be the start of a subdirectory.

Is there a better way?
4 REPLIES 4
Jeroen Peereboom
Honored Contributor
Solution

Re: counting sub-directories

Gord,

try
find . -type d | wc -l

(-type d: only directories).
If the count is approx the same as the ls -R, than it's OK?!

JP
Steven E. Protter
Exalted Contributor

Re: counting sub-directories

I kind of like our way.

Its not very processor intensive.

numsub=$(ls -R grep "./" |wc -l)
export numsub

Now I know the number of subbies.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Gord Moore
Frequent Advisor

Re: counting sub-directories

Slight difference in the counts, but either way tells me there are lots of sub-dirs out there.



> find . -type d | wc -l
31496
> ls -R | grep "./" | wc -l
31756


Thanks.
H.Merijn Brand (procura
Honored Contributor

Re: counting sub-directories

find should - in general - be the fastest, but they won't always give the same result.

sh-2.05b$ time perl -lMFile::Find -e'END{print$n}find(sub{-d&&$n++},".")'
19

real 0m0.109s
user 0m0.110s
sys 0m0.000s
sh-2.05b$ time find . -type d | wc -l
19

real 0m0.018s
user 0m0.010s
sys 0m0.010s
sh-2.05b$ time ls -R | grep "./" | wc -l
18

real 0m0.042s
user 0m0.020s
sys 0m0.020s
sh-2.05b$
timex

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn