1. 程式人生 > >tree 以樹行形結構顯示目錄下的內容

tree 以樹行形結構顯示目錄下的內容

base gpo nor cal out pos rect .bashrc 文件的

1. 命令功能

  tree中文意思“樹”,以樹形結構顯示目錄內容。、

2. 語法格式

  tree [option] [directory]

  tree 選項 目錄

3. 使用範例

當最小化安裝linux時,是沒有安裝tree命令的。

範例1 : 不帶參數執行tree,顯示/bin下內容

[root@localhost home]#

[root@localhost home]# cd /bin

[root@localhost bin]# tree

.

├── arch

├── awk -> gawk

├── basename

├── bash

├── cat

範例2:顯示/home/cxf目錄下全部目錄樹

[cxf@localhost ~]$ tree -a

.

├── abc

├── .bash_history

├── .bash_logout

├── .bash_profile

├── .bashrc

├── .lesshst

├── old

│ ├── a

│ ├── b

範例3:只列出目錄的目錄樹

[cxf@localhost ~]$ tree -d

.

├── old

│ ├── a

│ ├── b

│ ├── c

範例4:顯示文件的全路徑

[cxf@localhost ~]$ tree -f

.

├── ./abc

└── ./test

├── ./test/dir1

├── ./test/dir2

├── ./test/dir3

├── ./test/dir4

└── ./test/dir5

6 directories, 1 file

[cxf@localhost ~]$ tree -f /home/cxf

/home/cxf

├── /home/cxf/abc

└── /home/cxf/test

├── /home/cxf/test/dir1

├── /home/cxf/test/dir2

├── /home/cxf/test/dir3

├── /home/cxf/test/dir4

└── /home/cxf/test/dir5

6 directories, 1 file

範例5:顯示2層目錄樹

[cxf@localhost ~]$ tree -L 2

.

├── abc

└── test

├── dir1

├── dir2

├── dir3

├── dir4

└── dir5

6 directories, 1 file

[cxf@localhost ~]$ tree -L 2 --noreport

.

├── abc

└── test

├── dir1

├── dir2

├── dir3

├── dir4

└── dir5

tree 以樹行形結構顯示目錄下的內容