zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    shell中test命令方法详解
    Linux 查看端口使用情况
    jboss 报错处理及端口修改
    jboss的使用和安装
    python 关于列表的增删改查及个别的命令
    Cisco Cat4500系列High CPU故障步骤摘要
    Services: ARP Caching
    Passive Client Feature
    BGP前缀过滤(正则表达式)
    Cisco Spectrum Expert(Wave2 AP)
  • 原文地址:https://www.cnblogs.com/architectforest/p/12880712.html
Copyright © 2011-2022 走看看