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命令查看。
總結
以上是生活随笔為你收集整理的Linux查看所有子文件夹及文件的数量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python坐标表示_已知经纬度坐标求两
- 下一篇: linux 无法加载动态库,51CTO博