Handling space in parameters
by rac8006 from LinuxQuestions.org on (#5A91A)
I've searched every where I can think of and can't find an answer. I'm trying to find all of the directories in a partition and count the files. The problem that I'm having is that some of the directory names have a space in them. I did the following:
find . -maxdepth 1 -type d -print > dirs
then I wanted to do for i in `cat dirs`
do
echo -n $i
find "$i" -print|wc
done
I tried several different things but none of the worked.
What I finally got to work was
find . -maxdepth 1 -type d -exec sh myscript.sh {} \;
myscript.sh
echo -n "$1"
find "$@" -print|wc
Is there a better way to do this?
Thanks


find . -maxdepth 1 -type d -print > dirs
then I wanted to do for i in `cat dirs`
do
echo -n $i
find "$i" -print|wc
done
I tried several different things but none of the worked.
What I finally got to work was
find . -maxdepth 1 -type d -exec sh myscript.sh {} \;
myscript.sh
echo -n "$1"
find "$@" -print|wc
Is there a better way to do this?
Thanks