綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|論壇轉(zhuǎn)帖|廠商大全

綠色資源網(wǎng)

技術(shù)教程
您的位置:首頁操作系統(tǒng)linux → Linux查看所有子文件夾及文件的數(shù)量

Linux查看所有子文件夾及文件的數(shù)量

我要評論 2012/09/26 11:31:56 來源:綠色資源網(wǎng) 編輯:sonlywya.cn [ ] 評論:0 點(diǎn)擊:249次

find命令查看(推薦):

所有子目錄的數(shù)量:

[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 --正確
結(jié)果不同的原因:
[root@localhost ~]# find xkermulu -type d | more
xkermulu --輸出結(jié)果首行
[root@localhost ~]# find xkermulu/* -type d | more
xkermulu/examples --輸出結(jié)果首行

總結(jié):使用xkermulu/*不包含xkermulu這個父目錄,只輸出其下的子目錄。

所有文件的數(shù)量:

[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

總結(jié):du查看的結(jié)果為1111,子目錄的數(shù)量為124,文件數(shù)量為:1111-124=987,所以tree命令查看的結(jié)果應(yīng)該是不準(zhǔn)確,至于少計算了哪個文件,沒再查這個問題,推薦使用find命令查看。

關(guān)鍵詞:Linux

閱讀本文后您有什么感想? 已有 人給出評價!

  • 0 歡迎喜歡
  • 0 白癡
  • 0 拜托
  • 0 哇
  • 0 加油
  • 0 鄙視