Linux 中獲取當前目錄的樹形結構

2021-10-18 08:00:20 字數 2080 閱讀 1850

linux tree命令用於以樹狀圖列出目錄的內容。

執行tree指令,它會列出指定目錄下的所有檔案,包括子目錄裡的檔案。

tree [-aacddffgilnnpqstux][-i 《範本樣式》][-p 《範本樣式》][目錄...]
引數說明

以樹狀圖列出當前目錄結構。可直接使用如下命令:

tree
該命令有如下輸出結果:

# tree                   #以樹狀圖列出當前目錄結構  

. #當前目錄結構

8 directories, 48 files #統計資訊,該目錄共8個子目錄,48個檔案

獲取2層樹形結構

tree -l 2

Linux 獲取當前目錄

兩種方法 1.利用getcwd 函式取得當前工作目錄 相當於windows下的getcurrentdirectory 2.取得實際檔案目錄 相當於windows下的getmodulefilename 原理 每個程序在 proc下都有乙個以程序號命名的目錄。在該目錄下有exe檔案,該檔案是乙個鏈結檔案...

linux下獲取當前目錄

1.取得當前工作目錄 相當於windows下的getcurrentdirectory include stdio.h include stdlib.h include string.h include unistd.h int main else return 0 2.取得實際檔案目錄 相當於win...

獲取當前目錄

tchar exefullpath max path getmodulefilename getmodulehandle null exefullpath,max path tcsrchr exefullpath,t 1 0 這是一段獲得程式當前目錄的一段 這段 很簡單,唯一有點難度的就是最後一句 ...