W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
樹狀圖列出目錄的內(nèi)容
tree命令 以樹狀圖列出目錄的內(nèi)容。
tree(選項(xiàng))(參數(shù))
------- 列表選項(xiàng) -------
-a # 顯示所有文件和目錄。
-d # 顯示目錄名稱而非文件。
-l # 如遇到性質(zhì)為符號(hào)連接的目錄,直接列出該連接所指向的原始目錄。
-f # 在每個(gè)文件或目錄之前,顯示完整的相對(duì)路徑名稱。
-x # 將范圍局限在現(xiàn)行的文件系統(tǒng)中,若指定目錄下的某些子目錄,其存放于另一個(gè)文件系統(tǒng)上,則將該目錄予以排除在尋找范圍外。
-L level # 限制目錄顯示層級(jí)。
-R # Rerun tree when max dir level reached.
-P pattern # <范本樣式> 只顯示符合范本樣式的文件和目錄名稱。
-I pattern # Do not list files that match the given pattern.
--ignore-case # Ignore case when pattern matching.
--matchdirs # Include directory names in -P pattern matching.
--noreport # Turn off file/directory count at end of tree listing.
--charset X # Use charset X for terminal/HTML and indentation line output.
--filelimit # # Do not descend dirs with more than # files in them.
--timefmt <f> # Print and format time according to the format <f>.
-o filename # Output to file instead of stdout.
-------- 文件選項(xiàng) ---------
-q # 用“?”號(hào)取代控制字符,列出文件和目錄名稱。
-N # 直接列出文件和目錄名稱,包括控制字符。
-Q # Quote filenames with double quotes.
-p # 列出權(quán)限標(biāo)示。
-u # 列出文件或目錄的擁有者名稱,沒有對(duì)應(yīng)的名稱時(shí),則顯示用戶識(shí)別碼。
-g # 列出文件或目錄的所屬群組名稱,沒有對(duì)應(yīng)的名稱時(shí),則顯示群組識(shí)別碼。
-s # 列出文件和目錄大小。
-h # Print the size in a more human readable way.
--si # Like -h, but use in SI units (powers of 1000).
-D # 列出文件或目錄的更改時(shí)間。
-F # 在執(zhí)行文件,目錄,Socket,符號(hào)連接,管道名稱名稱,各自加上"*","/","@","|"號(hào)。
--inodes # Print inode number of each file.
--device # Print device ID number to which each file belongs.
------- 排序選項(xiàng) -------
-v # Sort files alphanumerically by version.
-t # 用文件和目錄的更改時(shí)間排序。
-c # Sort files by last status change time.
-U # Leave files unsorted.
-r # Reverse the order of the sort.
--dirsfirst # List directories before files (-U disables).
--sort X # Select sort: name,version,size,mtime,ctime.
------- 圖形選項(xiàng) ------
-i # 不以階梯狀列出文件和目錄名稱。
-A # 使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合。
-S # Print with CP437 (console) graphics indentation lines.
-n # Turn colorization off always (-C overrides).
-C # 在文件和目錄清單加上色彩,便于區(qū)分各種類型。
------- XML / HTML / JSON選項(xiàng) -------
-X # Prints out an XML representation of the tree.
-J # Prints out an JSON representation of the tree.
-H baseHREF # Prints out HTML format with baseHREF as top directory.
-T string # Replace the default HTML title and H1 header with string.
--nolinks # Turn off hyperlinks in HTML output.
---- 雜項(xiàng)選項(xiàng) ----
--version # 輸入版本信息。
--help # 打印使用幫助信息。
-- # Options processing terminator.
目錄:執(zhí)行tree指令,它會(huì)列出指定目錄下的所有文件,包括子目錄里的文件。
列出目錄/private/ 第一級(jí)文件名
tree /private/ -L 1
/private/
├── etc
├── tftpboot
├── tmp
└── var
忽略文件夾
tree -I node_modules # 忽略當(dāng)前目錄文件夾node_modules
tree -P node_modules # 列出當(dāng)前目錄文件夾node_modules的目錄結(jié)構(gòu)
tree -P node_modules -L 2 # 顯示目錄node_modules兩層的目錄樹結(jié)構(gòu)
tree -L 2 > /home/www/tree.txt # 當(dāng)前目錄結(jié)果存到 tree.txt 文件中
忽略多個(gè)文件夾
tree -I 'node_modules|icon|font' -L 2
非樹狀結(jié)構(gòu)列出目錄/private/下的所有文件
tree -if /private/
/private
/private/a1
/private/a2
/private/etc
/private/etc/b1
/private/etc/b2
/private/tftpboot
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: