Code:
for i in `find . -maxdepth 1 -mindepth 1 -type d -print`
is problematic because the list is split on IFS that defaults to space,tab,newline
You can improve it by setting IFS to newline only
Code:
oIFS=$IFS
IFS="
"
for i in `find . -maxdepth 1 -mindepth 1 -type d -print`
I would rather go for
read that by default reads one line i.e. at newline boundary. Still you should set IFS to preserve a leading space in a filename.
Code:
find . -maxdepth 1 -mindepth 1 -type d -print |
while IFS= read -r dir
do
find "$dir" -print | wc
done
This will only fail if a filename contains a newline (quite unusual but allowed).
The split on globs can even handle newline characters.
Code:
for dir in */ .[!.]*/
do
[ -d "$dir" ] &&
find "$dir" -print | wc
done
The trailing / in a glob already ensures directories, so the following test is only for the no-match case.
In bash you can alternatively do
Code:
shopt -s nullglob
find */ .[!.]*/ -print | wc
Because no test is needed and because find handles multiple start directories there is no need for a loop
Last but not least, bash has another option
Code:
shopt -s nullglob dotglob
find */ -print | wc
Now the * glob includes a .[!.]*