#!/bin/sh
#目录的深度
int_Depth=0
caldirdepth()
{
#for循环,假设目录的最大深度是10
for i in $(seq 10);
do
#for循环,这里用到了find
#find搜索$i的最小深度,加入$i深度没有文件或者文件夹,则为空,不会进入for循环
for file in $(find . -mindepth $i);
do
int_Depth=$i
break;
done
done
}
caldirdepth
echo $int_Depth
代码参照:
http://my.csdn.net/my/code/detail/63057