红穆笔记

tree

以樹的形式顯示當前目錄的內容

100% 瀏覽器本地處理 0 數據上傳

常用示例

顯示深度達到 “級數” 級的文件和目錄(其中 1 表示當前目錄)

tree -L {{級數}}

只顯示目錄

tree -d

同時顯示隱藏文件並開啓彩色輸出

tree -a -C

打印沒有縮進行的樹,顯示完整路徑(使用`-N`不轉義空格和特殊字符)

tree -i -f

以可讀格式打印每個文件節點的大小,目錄顯示其累積大小(類似在`du`命令中所示)

tree -s -h --du

使用通配符(glob)模式在樹層次結構中查找文件,並刪除不包含匹配文件的目錄

tree -P '{{*.txt}}' --prune

在樹層次結構中查找目錄,刪除不屬於所需目錄的目錄

tree -P {{文件夾名}} --matchdirs --prune

忽略指定目錄顯示樹

tree -I '{{目錄名1|目錄名2}}'

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Show the contents of the current directory as a tree. More information

Print files and directories up to `num` levels of depth (where 1 means the current directory)

tree -L {{num}}

Print directories only

tree -d

Print hidden files too with colorization on

tree -a -C

Print the tree without indentation lines, showing the full path instead (use `-N` to not escape non-printable characters)

tree -i -f

Print the size of each file and the cumulative size of each directory, in human-readable format

tree -s -h --du

Print files within the tree hierarchy, using a wildcard (`glob`) pattern, and pruning out directories that don't contain matching files

tree -P '{{*.txt}}' --prune

Print directories within the tree hierarchy, using the wildcard (`glob`) pattern, and pruning out directories that aren't ancestors of the wanted one

tree -P {{directory_name}} --matchdirs --prune

Print the tree ignoring the given directories

tree -I '{{directory_name1|directory_name2}}'

命令信息

命令名tree
用途以樹的形式顯示當前目錄的內容
適用平臺通用,Windows
示例數量8 條
官方文檔https://manned.org/tree
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

tree 命令是做什麼的?

以樹的形式顯示當前目錄的內容

tree 怎麼用?

頁面按場景列出了8 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

tree 最常用的操作是什麼?

顯示深度達到 “級數” 級的文件和目錄(其中 1 表示當前目錄):tree -L {{級數}}

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。