recursion地查找目录中文件的数量。
例如,如果目录one
有目录12 directories
并且这12 directories
每一个都有另外13 directories
。 和孙子(13个目录)有一个固定数量的文件。 我怎么find它有多less?
我试图以下列方式显示输出:
a/b/1/ -- 50 files a/b/2/ -- 10 files a/c/1/ -- 20 files.
find . -type d -exec sh -c 'printf "%s " "$0"; find "$0" -maxdepth 1 -type f -printf x | wc -c' {} \;
并为您的具体格式:
find . -type d -exec sh -c 'n=$(find "$0" -maxdepth 1 -type f -printf x | wc -c); printf "%s -- %s files\n" "$0" "$n"' {} \;
尝试:
find . -type f | wc -l
(它对在树中输出每个文件的行的命令(find. -type f))的输出的输出行(wc-l)进行计数)
[编辑]在阅读您的评论和更新后,我想出了这一个班轮:
tree -idf --noreport | while read line ; do echo $line ; find $line -maxdepth 1 -type f | wc -l ; done
for a in 1000000 1200000 1400000 1600000 1800000 2000000 2200000 2400000 800000 do for b in 10 14 18 2 22 26 30 34 38 42 46 6 do echo $a-$b find $a/$a-$b/ -type f -print | wc -l done done