[学习linux]Linux/Ubuntu tree 命令以树形结构显示文件夹目录结构

1、安装命令工具

1

sudo apt-get -y install tree

2、可以查看关于tree命令的帮助信息

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

$ tree --help

usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]]

        [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]

        [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]

        [--filelimit #] [<directory list>]

  -a            All files are listed.

  -d            List directories only.

  -l            Follow symbolic links like directories.

  -f            Print the full path prefix for each file.

  -i            Don't print indentation lines.

  -q            Print non-printable characters as '?'.

  -N            Print non-printable characters as is.

  -p            Print the protections for each file.

  -u            Displays file owner or UID number.

  -g            Displays file group owner or GID number.

  -s            Print the size in bytes of each file.

  -h            Print the size in a more human readable way.

  -D            Print the date of last modification.

  -F            Appends '/', '=', '*', or '|' as per ls -F.

  -v            Sort files alphanumerically by version.

  -r            Sort files in reverse alphanumeric order.

  -t            Sort files by last modification time.

  -x            Stay on current filesystem only.

  -L level      Descend only level directories deep.

-a列出所有文件。
-d列出目录。
-l遵循像目录这样的符号链接。
-f打印每个文件的完整路径前缀。
-i不打印缩进线。
-q将不可打印的字符打印为“?”.
-n按原样打印不可打印的字符。
-p打印每个文件的保护。
-u显示文件所有者或uid号。
-g显示文件组所有者或gid编号。
-s以字节为单位打印每个文件的大小。
-h以更人性化的方式打印尺寸。
-d打印上次修改的日期。
-f根据ls-f附加'/'、'='、'*'或''。
-v按版本对文件进行字母数字排序。
-r按相反的字母数字顺序对文件进行排序。
-t按上次修改时间对文件排序。
-X仅保留在当前文件系统上。
-L级只降低级别目录的深度。

3、使用方法(常用)

(1) 显示当前目录的树形结构

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

jianbao@jianbao-pc:/www/软件开发$ tree

.

├── PPT

│   └── PHP性能监控与优化.pptx

├── 电子书

│   ├── Linux.环境C程序设计.徐诚.扫描版.pdf

│   └── UNIX环境高级编程(中文第三版)_扫描版.pdf

├── 视频

│   └── PHP_C扩展

│       ├── PHP扩展开发教程.mp4

│       ├── swoole第三节第4部分.mp4

│       ├── swoole视频教程第3节 swoole服务器的进程_线程模型.mp4

│       └── 其他

│           ├── swoole-chat第二节第二部分.mp4

│           ├── swoole-chat第二节第三部分.mp4

└── 手册

    └── php_enhanced_zh.chm

(2) 只查看当前第一级的目录和文件

1

$ tree -L 1

(3) 只查看当前第二级的目录和文件

1

$ tree -L 2

(4) 只查看当前第N级的目录和文件

1

$ tree -L N

(5) 把目录结构信息保存到文本中

1

$ tree -L 2 > /home/php-note.com/tree.txt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值