Linux查(chá)看所有子文件夾(jiá)及文件的數量
find命令查看(推薦):
所有子(zǐ)目錄的數量:
[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 --輸出(chū)結果首行
[root@localhost ~]# find xkermulu/* -type d | more
xkermulu/examples --輸出結果首行
總結:使(shǐ)用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命令查看(kàn)(不推薦):
[root@localhost ~]# tree xkermulu
……
124 directories, 984 files
-----------------------------------------
[root@localhost ~]# tree xkermulu/
……
124 directories, 984 files
du命(mìng)令查看:
[root@localhost ~]# du -ah xkermulu/* | wc -l
1111
總結:du查看的結果為1111,子目錄的數量為124,文件數量為:1111-124=987,所以tree命令查看的(de)結果應該是不準確,至於少計算了哪個文件,沒再查這個問題(tí),推薦使用find命令查看(kàn)。
關鍵詞:Linux
閱讀(dú)本文(wén)後您有什麽感想? 已有 人給出評價!
- 0
- 0
- 0
- 0
- 0
- 0