linux

Linux查看所有子文件夹及文件的数量

日期:2012/09/26 11:31:56来源: 绿色资源网整理

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命令查看。

相关文章

相关下载

网友评论

我要评论...
没有更早的评论了
取消