#!/bin/sh
find /tmp/homework -maxdepth 1 -type d |
while read dir;
do
count=$(find "$dir" -type f | wc -l)
echo "$dir:$count"
done
#!/bin/bash
if [ $# -eq 0 ]
then dir=.
elif [ $# -eq 1 ]
then dir=$1
fi
while [ ! -d $dir ]
do
echo "Input an ordinary directory"
read dir
done
count=0
for sub_dir in `ls $dir`
do
array[$count]=$sub_dir
count=`expr $count + 1`
done
#echo ${array[@]} `ls array[@]|wc`
for((i=0;i<"${#array[*]}";i=i+1))
do
echo ${array[$i]} `ls $dir${array[$i]}|wc` "|"
done
exit 0
SHELL 获取目录下子目录的文件数
点赞
收藏