您现在的位置是:网站首页>内容内容

Linux查看所有子文件夹及文件的数量_资源网

2023-11-29 11:36:23512953070@qq.com140人已围观

简介 Linux查看所有子文件夹及文件的数量_资源网

find命令查看(推荐):

所有子目录的数量:

[root@localhost ~]# find xkermulu -type d | wc -l
125
[root@localhost ~]# find xkermulu/ -type d | wc -l
125
[root@localhost ~]# find xkermulu/* -type d | wc -l


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

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

所有文件的数量:

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

tree命令查看(不推荐):

[root@localhost ~]# tree xkermulu
……
124 directories, 984 files
-----------------------------------------
[root@localhost ~]# tree xkermulu/
……
124 directories, 984 files

du命令查看:

[root@localhost ~]# du -ah xkermulu/* | wc -l
1111

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

文章评论

发布内容
-六神源码网