Zatan (c) tree

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/wzj_110/article/details/100134948

A tree

Role : displays the contents of a directory tree structure

Note : to minimize the environmental is not installed packages tree

Thoughts : Does not display the meaning of the branches?

root 11:50:39 11:50:39 $tree /etc/yum.repos.d/
/etc/yum.repos.d/
├── redhat.repo
└── rhel7.5.repo

0 directories, 2 files
root 11:50:52 11:50:52 $tree -i /etc/yum.repos.d/  # 注意对比
/etc/yum.repos.d/
redhat.repo
rhel7.5.repo

0 directories, 2 files
root 11:51:02 11:51:02 $

# 明白树枝的含义了吧!

Supplement the relevant parameters

-L  参数后接数字,表示查看目录的层数,不带-L选项默认显示所有层数,贪婪匹配

-F  明确 *(file) /(firectory) =(socket) @(link) |(pipe) 所对应的文件类型

Frequently used scene

# 区分目录和文件

tree -L 1 -Fi -P /boot/ |grep /$

supplement

-A 使用ASNI绘图字符显示树状图而非以ASCII字符组合。
-C 在文件和目录清单加上色彩,便于区分各种类型。                 # 常用
-D 列出文件或目录的更改时间。
-g 列出文件或目录的所属群组名称,没有对应的名称时,则显示群组识别码。
-i 不以阶梯状列出文件或目录名称。
-I 不显示符合范本样式的文件或目录名称。
-l 如遇到性质为符号连接的目录,直接列出该连接所指向的原始目录。
-n 不在文件和目录清单加上色彩。
-N 直接列出文件和目录名称,包括控制字符。
-p 列出权限标示。                                            # 常用
-P 只显示符合范本样式的文件或目录名称。
-q 用"?"号取代控制字符,列出文件和目录名称。
-s 列出文件或目录大小。
-u 列出文件或目录的拥有者名称,没有对应的名称时,则显示用户识别码。
-x 将范围局限在现行的文件系统中,若指定目录下的某些子目录,其存放于另一个文件系统上,则将该子目录予以排除在寻找范围外。

Two mkdir

   make  directory

-m, --mode=MODE  # 权限
              set file mode (as in chmod), not a=rwx - umask

# 说明:不受配置文件中umask的影响!

-p, --parents    # 递归
              no error if existing, make parent directories as needed

-v, --verbose    # 创建过程
              print a message for each created directory

                 # 安全上下文(不常用)
-Z     set SELinux security context of each created  directory  to  the
              default type

Simple Application : Clone directory structure

# (1)生成相关的目录

mkdir -pv wzj/dir1_{1..2}/dir2_{1..2}

mkdir: created directory ‘wzj’
mkdir: created directory ‘wzj/dir1_1’
mkdir: created directory ‘wzj/dir1_1/dir2_1’
mkdir: created directory ‘wzj/dir1_1/dir2_2’
mkdir: created directory ‘wzj/dir1_2’
mkdir: created directory ‘wzj/dir1_2/dir2_1’
mkdir: created directory ‘wzj/dir1_2/dir2_2’

# (2)克隆目录结构

tree -fid --noreport wzj >> ~/wzj. txt
#  --noreport 不显示最后一行的统计信息!

# (3)还原目录

mkdir -p `cat ~/wzj.txt`

# 把每一行当作一个要创建的目录,依次执行!

Guess you like

Origin blog.csdn.net/wzj_110/article/details/100134948