• linux(centos8):使用tree命令查看目录结构


    一,tree命令的用途

    tree命令以树状图列出文件目录结构

    说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/

    说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,tree命令所属的包

    [liuhongdi@centos8 script]$ whereis tree
    tree: /usr/bin/tree /usr/share/man/man1/tree.1.gz
    
    [liuhongdi@centos8 script]$ rpm -qf /usr/bin/tree
    tree-1.7.0-15.el8.x86_64

    如果提示找不到tree命令,可以用dnf做安装

    [root@centos8 ~]# dnf install tree

    三,查看tree命令的版本和帮助

    1,查看版本:

    [root@centos8 ~]# tree --version
    tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro 

    2,查看帮助

    [root@centos8 ~]# tree --help

    3,查看手册

    [root@centos8 ~]# man tree

    四,tree命令常见的用法举例:

    1,列出目录下的文件(不显示隐藏文件)

    #不用加任何参数

    [root@centos8 ~]# tree /home/liuhongdi/

    2,列出目录下的文件,包括隐藏文件

    #-a:显示所有文件:包括隐藏文件在内

    [root@centos8 ~]# tree -a /home/liuhongdi/

    3, 指定目录的显示深度

    #-L level      Descend only level directories deep

    #-L 2:只显示两层目录

    [root@centos8 ~]# tree -L 2 /home/liuhongdi/

    4,显示文件的完整路径

    #-f:Print the full path prefix for each file

    [root@centos8 ~]# tree -f /home/liuhongdi/

    5,显示文件的大小:

    #-s:打印文件的大小

    #-h:以人性化方式打印大小

    [root@centos8 ~]# tree -sh /home/liuhongdi/

    6,只显示目录:

    #-d: List directories only

    [root@centos8 ~]# tree -d /home/liuhongdi/

    7,指定以json格式输出:

    #-J:Prints out an JSON representation of the tree

    [root@centos8 ~]# tree -J /home/liuhongdi/

    8,打印出文件属性:

    #-F :在执行文件,目录,Socket,符号连接,管道名称名称,各自加上"*","/","=","@","|"号

    [root@centos8 ~]# tree -F /home/liuhongdi/

    五,查看centos版本

    [root@centos8 ~]# cat /etc/redhat-release 
    CentOS Linux release 8.1.1911 (Core)
  • 相关阅读:
    redis
    java基础知识起步
    SQL(DML)语法
    jsp中的九大内置对象和四大作用域
    JDBC与javaBean
    javaScript知识点大全
    mysql数据库操作语法大全
    css前端知识点总结
    HTML前端小结
    代码整洁之道
  • 原文地址:https://www.cnblogs.com/architectforest/p/12880712.html
Copyright © 2020-2023  润新知