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

 

转载于:https://www.cnblogs.com/afish/p/3978521.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值