Linux tree命令

tree命令,以树的样式显示目录
tree - list contents of directories in a tree-like format.
-a 显示所有文件包括隐藏文件
[root@shuai ~]# tree -a
.
├── 1
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 14
├── 15
├── 16
├── 2
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 24
├── 25
├── 26
├── 3
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 34
├── 35
├── 36
├── anaconda-ks.cfg
├── .bash_history
├── .bash_logout
├── .bash_profile
├── .bashrc
├── .cshrc
├── date
├── install.log
├── install.log.syslog
└── .tcshrc


48 directories, 10 files
[root@shuai ~]# 


-d 只显示目录
[root@shuai ~]# tree -d
.
├── 1
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 14
├── 15
├── 16
├── 2
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 24
├── 25
├── 26
├── 3
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 34
├── 35
└── 36


48 directories
[root@shuai ~]# 


-L + 数字  显示级数
[root@shuai ~]# tree -L 3
.
├── 1
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 14
├── 15
├── 16
├── 2
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 24
├── 25
├── 26
├── 3
│   ├── 4
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   ├── 5
│   │   ├── 7
│   │   ├── 8
│   │   └── 9
│   └── 6
│       ├── 7
│       ├── 8
│       └── 9
├── 34
├── 35
├── 36
├── anaconda-ks.cfg
├── date
├── install.log
└── install.log.syslog
-f 显示完整的路径,为每一个显示完整路径
[root@shuai ~]# tree -dLf 3
.
├── ./1
│   ├── ./1/4
│   │   ├── ./1/4/7
│   │   ├── ./1/4/8
│   │   └── ./1/4/9
│   ├── ./1/5
│   │   ├── ./1/5/7
│   │   ├── ./1/5/8
│   │   └── ./1/5/9
│   └── ./1/6
│       ├── ./1/6/7
│       ├── ./1/6/8
│       └── ./1/6/9
├── ./14
├── ./15
├── ./16
├── ./2
│   ├── ./2/4
│   │   ├── ./2/4/7
│   │   ├── ./2/4/8
│   │   └── ./2/4/9
│   ├── ./2/5
│   │   ├── ./2/5/7
│   │   ├── ./2/5/8
│   │   └── ./2/5/9
│   └── ./2/6
│       ├── ./2/6/7
│       ├── ./2/6/8
│       └── ./2/6/9
├── ./24
├── ./25
├── ./26
├── ./3
│   ├── ./3/4
│   │   ├── ./3/4/7
│   │   ├── ./3/4/8
│   │   └── ./3/4/9
│   ├── ./3/5
│   │   ├── ./3/5/7
│   │   ├── ./3/5/8
│   │   └── ./3/5/9
│   └── ./3/6
│       ├── ./3/6/7
│       ├── ./3/6/8
│       └── ./3/6/9
├── ./34
├── ./35
└── ./36


48 directories
[root@shuai ~]# 


-i去除目录的树枝--
[root@shuai ~]# tree -dLfi 3
.
./1
./1/4
./1/4/7
./1/4/8
./1/4/9
./1/5
./1/5/7
./1/5/8
./1/5/9
./1/6
./1/6/7
./1/6/8
./1/6/9
./14
./15
./16
./2
./2/4
./2/4/7
./2/4/8
./2/4/9
./2/5
./2/5/7
./2/5/8
./2/5/9
./2/6
./2/6/7
./2/6/8
./2/6/9
./24
./25
./26
./3
./3/4
./3/4/7
./3/4/8
./3/4/9
./3/5
./3/5/7
./3/5/8
./3/5/9
./3/6
./3/6/7
./3/6/8
./3/6/9
./34
./35
./36


48 directories

[root@shuai ~]# 

-F区分目录和文件

[root@shuai ~]# tree -F

.

├── 1/

│   ├── 4/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   ├── 5/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   └── 6/

│       ├── 7/

│       ├── 8/

│       └── 9/

├── 14/

├── 15/

├── 16/

├── 2/

│   ├── 4/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   ├── 5/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   └── 6/

│       ├── 7/

│       ├── 8/

│       └── 9/

├── 24/

├── 25/

├── 26/

├── 3/

│   ├── 4/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   ├── 5/

│   │   ├── 7/

│   │   ├── 8/

│   │   └── 9/

│   └── 6/

│       ├── 7/

│       ├── 8/

│       └── 9/

├── 34/

├── 35/

├── 36/

├── anaconda-ks.cfg

├── date

├── install.log

└── install.log.syslog

 

48 directories, 4 files

[root@shuai ~]# 

末尾带/的都是目录

点击打开链接
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值