sorry to reply late. i have used your method , it works. two more questions: 1.about syntax (r "$d") i didn't find any introduction in 'info bash'. could you tell me how could find the explanation of '( )'?
2.about synax "find /testcase -name autotest.sh -perm /111 -execdir bash -c ./autotest.sh \;" what does the last '\' mean? 3x again > On Wed, 2007-11-14 at 00:51 -0700, Mike Stroyan wrote: > On Wed, Nov 14, 2007 at 01:38:01PM +0800, 龙海涛 wrote: > ... > > but now what i want to do is write a shell script , call all the > > autotest.sh in every leaf-directory. > > You could do that with a recursive function that descends into > each directory. Using ( ) around the cd to a subdirectory will > return to the previous directory at the closing parenthesis. > Looking for autotest.sh files in just leaf directories would be > harder than executing those files in all directories of the tree. > It would be possible to test for the presence of subdirectories > first and suppress execution of autotest.sh in non-leaf directories. > But I will assume that you don't actually require that. > > r () > { > cd "$1" > if [ -x autotest.sh ]; then > ./autotest.sh; > fi; > for d in * > do > if [ -d "$d" ]; then > ( r "$d" ) > fi; > done > } > > Then run > r /testcase > to acutally use the recursive function on /testcase. > > But the find command is very good at doing this as well. > > find /testcase -name autotest.sh -perm /111 -execdir bash -c ./autotest.sh \; >