zoukankan      html  css  js  c++  java
  • Linux查看所有子文件夹及文件的数量

    find命令查看(推荐):

    所有子目录的数量:

    [root@localhost ~]# find afish -type d | wc -l
    158
    [root@localhost ~]# find afish/ -type d | wc -l
    158
    [root@localhost ~]# find afish/* -type d | wc -l
    157 --正确

    结果不同的原因:
    [root@localhost ~]# find afish -type d | more
    afish --输出结果首行
    [root@localhost ~]# find afish/* -type d | more
    afish/examples --输出结果首行

    总结:使用afish/*不包含afish这个父目录,只输出其下的子目录。

    所有文件的数量:

    [root@localhost ~]# find afish -type f | wc -l
    981
    [root@localhost ~]# find afish/ -type f | wc -l
    981
    [root@localhost ~]# find afish/* -type f | wc -l
    981

    tree命令查看(不推荐):

    [root@localhost ~]# tree afish
    ……
    157 directories, 978 files
    -----------------------------------------
    [root@localhost ~]# tree afish/
    ……
    157 directories, 978 files

    du命令查看:

    [root@localhost ~]# du -ah afish/* | wc -l
    1138

    总结:du查看的结果为1138,子目录的数量为157,文件数量为:1138-157=981,所以tree命令查看的结果应该是不准确,至于少计算了哪个文件,没再查这个问题,推荐使用find命令查看。

    转载请注明出处!小鱼阁工作室 -专注zencart建站,织梦企业建站,ecshop商城,二次开发,产品采集,模板修改!技术QQ 631992791
  • 相关阅读:
    C#中 时间戳与普通时间格式的转换
    关于Litjson的简单使用
    Unity 前端开发积累 第二篇
    《大话数据结构》--- 第六章 树
    《大话数据结构》--- 第五章 串
    获取RDP连接中密码的方法
    CMD打包文件,解压文件
    泛微OA7.0下载7.1下载
    [ASP.NET]书店后台开发-模板页
    [JSP]用户注册
  • 原文地址:https://www.cnblogs.com/afish/p/3978521.html
Copyright © 2011-2022 走看看