Linux中如何查看指定文件夹内各个子文件夹内的文件数量
这篇文章主要介绍了Linux中如何查看指定文件夹内各个子文件夹内的文件数量,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
count脚本
#!/bin/sh numOfArgs=$# if [ $numOfArgs -ne 1 ]; then echo -e "Usage: \nbash $0 dirForCount" exit -1 fi # args ROOTDIR=$1 # core part find $ROOTDIR -maxdepth 1 -type d | sort | while read dir; do count=$(find "$dir" -type f | wc -l) echo "$dir: $count" done
执行
$ bash count.sh benchmark
benchmark: 2317
benchmark/0: 20
benchmark/1: 891
benchmark/2: 65
benchmark/3: 13
benchmark/4: 1328
感谢你能够认真阅读完这篇文章,希望小编分享的“Linux中如何查看指定文件夹内各个子文件夹内的文件数量”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注行业资讯频道,更多相关知识等着你来学习!