1#!/bin/sh 2find /tmp/homework -maxdepth 1 -type d | 3while read dir; 4do 5 count=$(find "$dir" -type f | wc -l) 6 echo "$dir:$count" 7done 8 9#!/bin/bash 10if [ $# -eq 0 ] 11then dir=. 12elif [ $# -eq 1 ] 13then dir=$1 14fi 15while [ ! -d $dir ] 16do 17 echo "Input an ordinary directory" 18 read dir 19done 20count=0 21for sub_dir in `ls $dir` 22do 23 array[$count]=$sub_dir 24 count=`expr $count + 1` 25done 26#echo ${array[@]} `ls array[@]|wc` 27for((i=0;i<"${#array[*]}";i=i+1)) 28do 29 echo ${array[$i]} `ls $dir${array[$i]}|wc` "|" 30done 31exit 0
SHELL 获取目录下子目录的文件数
Wesley13
2021-10-11
1215 1 0
点赞
收藏
评论区
加载中...