Linux命令之tree
tree
功能說明:
以樹狀圖列出目錄的內(nèi)容
語法:
tree [-aACdDfFgilnNpqstux] [-l <范本樣式>] [-p <范本樣式>] [目錄]
補(bǔ)充說明:
執(zhí)行tree指令,它會列出指定目錄下的所有文件,包括子目錄里的文件
參數(shù):
-a :顯示所有文件和目錄
-A :使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合
-c :在文件和目錄清單加上色彩,便于區(qū)分各種類型
-d :顯示目錄名稱而非內(nèi)容
-D :列出文件或目錄的更改時間
-f ?:在每個文件或目錄之前,顯示完整的相對路徑
-F :在執(zhí)行文件,目錄,Socket,符號鏈接,管道名稱,各自加上 * ?/ ?= @ ?|
-g :列出文件或目錄的所屬組名稱,沒有對應(yīng)的名稱時,則顯示群組織識別碼
-i :不以階梯狀列出文件或目錄名稱
-l <范本樣式> :不顯示符合范本樣式的文件或目錄名稱
-l :如遇到性質(zhì)為符號鏈接的目錄,直接列出該鏈接所指向的原始目錄
-n :不在文件和目錄清單加上色彩
-N :直接列出文件和目錄名稱,包括控制字符
-p :列出權(quán)限標(biāo)示
-p <范本樣式> :只顯示符合范本樣式的文件或目錄名稱
-q :用“?”號取代控制字符,列出文件和目錄名稱
-s :列出文件或目錄大小
-t :用文件和目錄的更改時間排序
-u :列出文件或目錄的擁有者名稱,沒有對應(yīng)的名稱時,則顯示用戶識別碼
-x :將范圍局限在現(xiàn)行的文件系統(tǒng)中,若指定目錄下的某些子目錄,其存放于另一個文件
系統(tǒng)上,則將該子目錄予以排除在尋找范圍外。
命令實踐:
[root@yubing ~]#tree
.
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test
| ? |-- wodi.gz
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
|--oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -a ? 顯示所有目錄
.
|--.bash_history
|-- .bash_logout
|-- .bash_profile
|-- .bashrc
|-- .cshrc
|-- .tcshrc
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test
| ? |-- wodi.gz
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
|--oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
6 directories,20 files
[root@yubing ~]#tree -A ? 使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合
.
tqqanaconda-ks.cfg
tqq crontab1
tqq crontab2-> /etc/crontab
tqq install.log
tqqinstall.log.syslog
tqq oldboy
x ? tqq ext
x ? x ?mqq oldboy
x ? tqq jeacen
x ? tqq oldboy
x ? tqq test
x ? tqq wodi.gz
x ? tqq xiaodong
x ? tqq xiaofan
x ? tqq xingfujie
x ? mqq yingsui.gz
tqqoldboy.tar.gz
tqq yubing.txt
tqq yubing.txt1
mqq yubing.txt2
6 directories,14 files
[root@yubing ~]# tree -d ? ? 顯示目錄名稱而非內(nèi)容
.
`-- oldboy
? ?|-- ext
? ?|-- test
? ?|-- xiaodong
? ?|-- xiaofan
? ?`-- xingfujie
6 directories
[root@yubing ~]#tree -D ? ?列出文件或目錄的更改時間
.
|-- [Apr ?7 1:47] ?anaconda-ks.cfg
|-- [Jan ?6 2007] ?crontab1
|-- [Apr ?8 4:06] ?crontab2 -> /etc/crontab
|-- [Apr ?7 1:47] ?install.log
|-- [Apr ?7 1:46] ?install.log.syslog
|-- [Oct 28 ?2011] oldboy
| ? |-- [Oct 28 2011] ?ext
| ? | ?`-- [Oct 28 ?2011] ?oldboy
| ? |-- [Oct 28 2011] ?jeacen
| ? |-- [Oct 28 2011] ?oldboy
| ? |-- [Oct 27 2011] ?test
| ? |-- [Oct 27 2011] ?wodi.gz
| ? |-- [Oct 27 2011] ?xiaodong
| ? |-- [Oct 27 2011] ?xiaofan
| ? |-- [Oct 27 2011] ?xingfujie
| ? `-- [Oct 27 2011] ?yingsui.gz
|-- [Apr 1414:13] ?oldboy.tar.gz
|-- [Apr 17 ?1:30] yubing.txt
|-- [Apr 17 ?1:31] yubing.txt1
`-- [Apr 17 ?1:31] yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -f ? ?在每個文件或目錄前顯示完整路徑
.
|--./anaconda-ks.cfg
|-- ./crontab1
|-- ./crontab2-> /etc/crontab
|--./install.log
|--./install.log.syslog
|-- ./oldboy
| ? |-- ./oldboy/ext
| ? | ?`-- ./oldboy/ext/oldboy
| ? |-- ./oldboy/jeacen
| ? |-- ./oldboy/oldboy
| ? |-- ./oldboy/test
| ? |-- ./oldboy/wodi.gz
| ? |-- ./oldboy/xiaodong
| ? |-- ./oldboy/xiaofan
| ? |-- ./oldboy/xingfujie
| ? `-- ./oldboy/yingsui.gz
|--./oldboy.tar.gz
|-- ./yubing.txt
|--./yubing.txt1
`--./yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -F ? 在執(zhí)行文件,目錄,Socket,符號鏈接,管道名稱,各自加上
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? * ? ? / ? ? ?@ ? ? ? = ? ? ? ?| ? ?
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy/
| ? |-- ext/
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test/
| ? |-- wodi.gz
| ? |-- xiaodong/
| ? |-- xiaofan/
| ? |-- xingfujie/
| ? `-- yingsui.gz
|--oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
[root@yubing ~]# tree -g ? ? 列出文件或目錄的所屬組名稱
.
|-- [root ? ?] anaconda-ks.cfg
|-- [root ? ?] crontab1
|-- [root ? ?] crontab2 -> /etc/crontab
|-- [root ? ?] install.log
|-- [root ? ?] install.log.syslog
|-- [root ? ?] oldboy
| ? |-- [root ? ] ?ext
| ? | ?`-- [root ? ?] ?oldboy
| ? |-- [root ? ] ?jeacen
| ? |-- [root ? ] ?oldboy
| ? |-- [root ? ] ?test
| ? |-- [root ? ] ?wodi.gz
| ? |-- [root ? ] ?xiaodong
| ? |-- [root ? ] ?xiaofan
| ? |-- [root ? ] ?xingfujie
| ? `-- [root ? ] ?yingsui.gz
|-- [root ? ?] oldboy.tar.gz
|-- [root ? ?] yubing.txt
|-- [root ? ?] yubing.txt1
`-- [root ? ?] yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -i ? ? ? ? ? 不以階梯狀列出文件或目錄名稱
.
anaconda-ks.cfg
crontab1
crontab2 ->/etc/crontab
install.log
install.log.syslog
oldboy
ext
oldboy
jeacen
oldboy
test
wodi.gz
xiaodong
xiaofan
xingfujie
yingsui.gz
oldboy.tar.gz
yubing.txt
yubing.txt1
yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -l ? ? ? ? 如遇到性質(zhì)為符號鏈接的目錄,直接列出該鏈接所指向的原始目錄
.
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test
| ? |-- wodi.gz
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
|-- oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -N ? ? ? ?直接列出文件和目錄名稱,包括控制字符
.
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test
| ? |-- wodi.gz
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
|--oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -p ? ? ? ? ? ?列出權(quán)限標(biāo)示
.
|--[-rw-------] ?anaconda-ks.cfg
|--[-rw-r--r--] ?crontab1
|-- [lrwxrwxrwx] ?crontab2 -> /etc/crontab
|--[-rw-r--r--] ?install.log
|--[-rw-r--r--] ?install.log.syslog
|--[drwxr-xr-x] ?oldboy
| ? |-- [drwxr-xr-x] ?ext
| ? | ?`-- [-rw-r--r--] ?oldboy
| ? |-- [-rw-r--r--] ?jeacen
| ? |-- [-rw-r--r--] ?oldboy
| ? |-- [drwxr-xr-x] ?test
| ? |-- [-rw-r--r--] ?wodi.gz
| ? |-- [drwxr-xr-x] ?xiaodong
| ? |-- [drwxr-xr-x] ?xiaofan
| ? |-- [drwxr-xr-x] ?xingfujie
| ? `-- [-rw-r--r--] ?yingsui.gz
|--[-rw-r--r--] ?oldboy.tar.gz
|--[-rw-r--r--] ?yubing.txt
|--[-rw-r--r--] ?yubing.txt1
`--[-rw-r--r--] ?yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -q ? 用“?”號取代控制字符,列出文件和目錄名稱
.
|--anaconda-ks.cfg
|-- crontab1
|-- crontab2-> /etc/crontab
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- jeacen
| ? |-- oldboy
| ? |-- test
| ? |-- wodi.gz
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
|--oldboy.tar.gz
|-- yubing.txt
|-- yubing.txt1
`-- yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -s ? ? ? 列出文件或目錄大小
.
|-- [ ? ? ?887] anaconda-ks.cfg
|-- [ ? ? ?255] crontab1
|-- [ ? ? ? 12] crontab2 -> /etc/crontab
|-- [ ? ?23947] install.log
|-- [ ? ? 3619] install.log.syslog
|-- [ ? ? 4096] oldboy
| ? |-- [ ? ?4096] ?ext
| ? | ?`-- [ ? ? ? 35] ?oldboy
| ? |-- [ ? ? ? 0] ?jeacen
| ? |-- [ ? ? ?35] ?oldboy
| ? |-- [ ? ?4096] ?test
| ? |-- [ ? ? ?25] ?wodi.gz
| ? |-- [ ? ?4096] ?xiaodong
| ? |-- [ ? ?4096] ?xiaofan
| ? |-- [ ? ?4096] ?xingfujie
| ? `-- [ ? ? ?28] ?yingsui.gz
|-- [ ? ? ?425] oldboy.tar.gz
|-- [ ? ? ? 21] yubing.txt
|-- [ ? ? ? 11] yubing.txt1
`-- [ ? ? ? 32] yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -t ? ? ?用文件和目錄的更改時間排序
.
|-- yubing.txt2
|-- yubing.txt1
|-- yubing.txt
|--oldboy.tar.gz
|-- crontab2-> /etc/crontab
|--anaconda-ks.cfg
|-- install.log
|--install.log.syslog
|-- oldboy
| ? |-- ext
| ? | ?`-- oldboy
| ? |-- oldboy
| ? |-- jeacen
| ? |-- wodi.gz
| ? |-- test
| ? |-- xiaodong
| ? |-- xiaofan
| ? |-- xingfujie
| ? `-- yingsui.gz
`-- crontab1
6 directories,14 files
[root@yubing ~]#tree -u ? ?列出文件或目錄的擁有者名稱
.
|-- [root ? ?] anaconda-ks.cfg
|-- [root ? ?] crontab1
|-- [root ? ?] crontab2 -> /etc/crontab
|-- [root ? ?] install.log
|-- [root ? ?] install.log.syslog
|-- [root ? ?] oldboy
| ? |-- [root ? ] ?ext
| ? | ?`-- [root ? ?] ?oldboy
| ? |-- [root ? ] ?jeacen
| ? |-- [root ? ] ?oldboy
| ? |-- [root ? ] ?test
| ? |-- [root ? ] ?wodi.gz
| ? |-- [root ? ] ?xiaodong
| ? |-- [root ? ] ?xiaofan
| ? |-- [root ? ] ?xingfujie
| ? `-- [root ? ] yingsui.gz
|-- [root ? ?] oldboy.tar.gz
|-- [root ? ?] yubing.txt
|-- [root ? ?] yubing.txt1
`-- [root ? ?] yubing.txt2
6 directories,14 files
[root@yubing ~]#tree -u /home ? ?列出/home下文件或目錄的擁有者名稱
/home
`-- [yubing ?] yubing
1 directory, 0files
[root@yubing ~]#tree -u /tmp
/tmp
|-- [root ? ?] oldboy
| ? |-- [root ? ] ?ext
| ? | ?`-- [root ? ?] ?oldboy
| ? |-- [root ? ] ?jeacen
| ? |-- [root ? ] ?oldboy
| ? |-- [root ? ] ?test
| ? |-- [root ? ] ?wodi.gz
| ? |-- [root ? ] ?xiaodong
| ? |-- [root ? ] ?xiaofan
| ? |-- [root ? ] ?xingfujie
| ? `-- [root ? ] ?yingsui.gz
|-- [root ? ?] ssh-otUIue2559
| ? `-- [root ? ] ?agent.2559
`-- [root ? ?] yubing
7 directories, 7files
轉(zhuǎn)載于:https://blog.51cto.com/yubing208/1197887
總結(jié)
以上是生活随笔為你收集整理的Linux命令之tree的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树莓派安装Ubuntu MATE及ROS
- 下一篇: 哪个linux桌面有电池显示,(求助!!