function ergodic(){ for file in ` ls $1 ` #遍历目录 do if [ -d $1"/"$file ] #判断是否是目录 then ergodic $1"/"$file elif [ ${file##*.} = "sh" ] #判断后缀名是否为sh ${file%.*}”获取不含后缀的文件 then chmod u+x $1"/"$file fi done } INIT_PATH="./home" ergodic $INIT_PATH