递归文件目录打印所有文件名称

遍历文件夹,获取各个文件夹下面的文件

function listFiles()
{
        #1st param, the dir name
        #2nd param, the aligning space
        for file in `ls $1`;
        do
                if [ -d "$1/$file" ]; then
                    #echo "$2$file"
		    listFiles "$1/$file" "   $2"
                else
                    #echo "$2$file"
		    if [[ $file =~ ".php" ]]
		    then
		    	~/odp3.2/php/bin/php -l "$1/$file"
		    fi
                fi
        done
}
listFiles $1 ""

  

猜你喜欢

转载自www.cnblogs.com/greatai/p/10009792.html
今日推荐