循环统计每个目录下文件的数量

#!/bin/bash
myfunc()
{
	for x in $(ls)
	do
		if [ -d "$x" ] ; then
			kel=`pwd`;
			echo "$kel/$x目录的数量为"`ls -l "$kel"/"$x"  |grep -v total |wc -l`;
			cd "$x";
			myfunc;
			cd ..
		else
		echo -n "";
		fi
		done
}
myfunc


在需要统计的目录下执行此脚本即可

for linux and python
原文地址:https://www.cnblogs.com/kellyseeme/p/5525184.html