Linux命令--tree--使用/详解/实例

网友投稿 683 2022-11-23

Linux命令--tree--使用/详解/实例

Linux命令--tree--使用/详解/实例

原文网址: 见:​​Linux命令--tree--使用/详解/实例_IT利刃出鞘的博客-CSDN博客​​

简介

本文用示例介绍Linux的tree命令的用法。

tree命令可以以树状结构查看目录结构。

选项

列表选项

-a            # 显示所有文件和目录。-d            # 显示目录名称而非文件。-l            # 如遇到性质为符号连接的目录,直接列出该连接所指向的原始目录。-f            # 在每个文件或目录之前,显示完整的相对路径名称。-x            # 将范围局限在现行的文件系统中。若指定目录下的某些子目录,其存放于另一个文件系统上,则将该目录予以排除在寻找范围外。-L level      # 限制目录显示层级。-R            # Rerun tree when max dir level reached.-P pattern    # <范本样式> 只显示符合范本样式的文件和目录名称。-I pattern    # Do not list files that match the given pattern.--ignore-case # Ignore case when pattern matching.--matchdirs   # Include directory names in -P pattern matching.--noreport    # Turn off file/directory count at end of tree listing.--charset X   # Use charset X for terminal/HTML and indentation line output.--filelimit # # Do not descend dirs with more than # files in them.--timefmt # Print and format time according to the format .-o filename   # Output to file instead of stdout.

文件选项

-q            # 用“?”号取代控制字符,列出文件和目录名称。-N            # 直接列出文件和目录名称,包括控制字符。-p            # 列出权限标示。-u            # 列出文件或目录的拥有者名称,没有对应的名称时,则显示用户识别码。-g            # 列出文件或目录的所属群组名称,没有对应的名称时,则显示群组识别码。-s            # 列出文件和目录大小。-D            # 列出文件或目录的更改时间。-F            # 在执行文件,目录,Socket,符号连接,管道名称名称,各自加上"*","/","@","|"号。-Q            # Quote filenames with double quotes.-h            # Print the size in a more human readable way.--si          # Like -h, but use in SI units (powers of 1000).--inodes      # Print inode number of each file.--device      # Print device ID number to which each file belongs.

排序选项

-t            # 用文件和目录的更改时间排序。-v            # Sort files alphanumerically by version.-c            # Sort files by last status change time.-U            # Leave files unsorted.-r            # Reverse the order of the sort.--dirsfirst   # List directories before files (-U disables).--sort X      # Select sort: name,version,size,mtime,ctime.

图形选项

-i            # 不以树状列出文件和目录名称。-A            # 使用ASNI绘图字符显示树状图而非以ASCII字符组合。-C            # 在文件和目录清单加上色彩,便于区分各种类型。-S            # Print with CP437 (console) graphics indentation lines.-n            # Turn colorization off always (-C overrides).

XML / HTML / JSON选项

-X            # Prints out an XML representation of the tree.-J            # Prints out an JSON representation of the tree.-H baseHREF   # Prints out HTML format with baseHREF as top directory.-T string     # Replace the default HTML title and H1 header with string.--nolinks     # Turn off hyperlinks in HTML output.

杂项选项

--version     # 输入版本信息。--help        # 打印使用帮助信息。--            # Options processing terminator.

示例

完整文件结构如下(tree -a):

.|-- .gitignore|-- .idea| |-- .gitignore| |-- compiler.xml| |-- encodings.xml| |-- jarRepositories.xml| |-- libraries| | |-- Maven__ch_qos_logback_logback_classic_1_2_7.xml| | |-- Maven__ch_qos_logback_logback_core_1_2_7.xml| | |-- ......| | `-- Maven__org_yaml_snakeyaml_1_27.xml| |-- misc.xml| |-- modules.xml| |-- vcs.xml| `-- workspace.xml|-- .mvn| `-- wrapper| |-- maven-wrapper.jar| `-- maven-wrapper.properties|-- HELP.md|-- demo_lock4j_SpringBoot.iml|-- mvnw|-- mvnw.cmd|-- pom.xml`-- src |-- main | |-- java | | `-- com | | `-- knife | | `-- demo | | `-- DemoLock4jSpringBootApplication.java | `-- resources | `-- application.yml `-- test `-- java `-- com `-- knife `-- demo

tree不加参数

命令:tree

结果:

可以发现,它没有显示出以点号开头的文件夹的内容。

显示所有

命令:tree -a

结果:

指定目录

命令:tree 目录名

结果:

指定层数

命令:tree -L 2

结果:

忽略文件夹+指定层数

命令:tree -I 'pom.xml|.idea' -aL 2

结果:

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:vue-cli3.0--多环境构建(模式和环境变量)--使用/实例
下一篇:CPU的功能和基本结构
相关文章

 发表评论

暂时没有评论,来抢沙发吧~