tree
Linux tree命令用于以樹狀圖列出目錄的內容,
執行tree指令,它會列出指定目錄下的所有檔案,包括子目錄里的檔案,
語法
tree [-aACdDfFgilnNpqstux][-I <范本樣式>][-P <范本樣式>][目錄...]
引數說明:
-
- -a 顯示所有檔案和目錄, - -A 使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合, - -C 在檔案和目錄清單加上色彩,便于區分各種型別, - -d 顯示目錄名稱而非內容, - -D 列出檔案或目錄的更改時間, - -f 在每個檔案或目錄之前,顯示完整的相對路徑名稱, - -F 在執行檔案,目錄,Socket,符號連接,管道名稱名稱,各自加上"*","/","=","@","|"號, - -g 列出檔案或目錄的所屬群組名稱,沒有對應的名稱時,則顯示群組識別碼, - -i 不以階梯狀列出檔案或目錄名稱, - -L level 限制目錄顯示層級, - -l 如遇到性質為符號連接的目錄,直接列出該連接所指向的原始目錄, - -n 不在檔案和目錄清單加上色彩, - -N 直接列出檔案和目錄名稱,包括控制字符, - -p 列出權限標示, - -P<范本樣式> 只顯示符合范本樣式的檔案或目錄名稱, - -q 用"?"號取代控制字符,列出檔案和目錄名稱, - -s 列出檔案或目錄大小, - -t 用檔案和目錄的更改時間排序, - -u 列出檔案或目錄的擁有者名稱,沒有對應的名稱時,則顯示用戶識別碼, - -x 將范圍局限在現行的檔案系統中,若指定目錄下的某些子目錄,其存放于另一個檔案系統上,則將該子目錄予以排除在尋找范圍外,
以樹狀圖列出當前目錄結構,可直接使用如下命令:
[root@localhost pgsql] tree
.
├── assets
│ └── postgresql-12.10.tar.gz
├── conf
│ ├── pg_hba.conf
│ ├── postgresql
│ └── postgresql.conf
├── install.py
├── install.pyc
└── services
└── postgresql-12.service
3 directories, 7 files
顯示2層目錄:
[root@localhost opt] tree -L 2
.
├── nta
│ ├── pom.xml
│ └── src
├── py_mysql
│ ├── bin
│ ├── core
│ ├── db
│ ├── doc
│ ├── log
│ ├── README.md
│ ├── templates
│ └── venv
├── Python-3.8.3
│ ├── aclocal.m4
│ ├── build
│ ├── CODE_OF_CONDUCT.md
│ ├── config.guess
│ ├── config.log
│ ├── config.status
│ ├── config.sub
│ ├── configure
│ ├── configure.ac
│ ├── Doc
│ ├── Grammar
│ ├── Include
│ ├── install-sh
│ ├── Lib
│ ├── libpython3.8.a
│ ├── LICENSE
│ ├── m4
│ ├── Mac
│ ├── Makefile
│ ├── Makefile.pre
│ ├── Makefile.pre.in
│ ├── Misc
│ ├── Modules
│ ├── Objects
│ ├── Parser
│ ├── PC
│ ├── PCbuild
│ ├── Programs
│ ├── pybuilddir.txt
│ ├── pyconfig.h
│ ├── pyconfig.h.in
│ ├── python
│ ├── Python
│ ├── python-config
│ ├── python-config.py
│ ├── python-gdb.py
│ ├── README.rst
│ ├── setup.py
│ └── Tools
├── Python-3.8.3.tgz
40 directories, 34 files
只顯示目錄,不顯示檔案:
[root@localhost pgsql] tree -d
.
├── assets
├── conf
└── services
3 directories
加顏色進行區分:


列出檔案或目錄大小
[root@localhost steps] tree -s -L 2
.
├── [ 85] basic
│ ├── [ 19] assets
│ ├── [ 31] conf
│ ├── [ 1213] install.py
│ ├── [ 1644] install.pyc
│ └── [ 31] services
├── [ 55] compiler
│ ├── [ 3950] install.py
│ ├── [ 4093] install.pyc
│ └── [ 20] rpms
├── [ 144] custom_python
│ ├── [ 254] assets
│ ├── [ 40] conf
│ ├── [ 3067] install.py
│ ├── [ 3653] install.pyc
│ ├── [ 31] python3-packages
│ ├── [ 108] python-packages
│ ├── [ 20] rpms
│ └── [ 29] services
按時間排序
[root@localhost steps] tree -t -L 1
.
├── params.py
├── compiler
├── dnsmasq
├── elasticsearch
├── go
├── params.pyc
├── nginx
├── optimization
本文來自博客園,作者:ivanlee717,轉載請注明原文鏈接:https://www.cnblogs.com/ivanlee717/p/16312582.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/481135.html
標籤:其他
下一篇:linux命令_tree
