Linux中查看指定文件夹内各个子文件夹内的文件数量

吾爱主题 阅读:128 2024-04-05 15:04:05 评论:0

count脚本

?
1 2 3 4 5 6 7 8 9 10 11 12 13 #!/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

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/tianzhaixing2013/article/details/85324818

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容