tree 数状型结构显示目录下的内容

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

原文地址:https://www.cnblogs.com/joechu/p/8611479.html