• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Linux命令:tree(3)

武飞扬头像
xuforeverlove
帮助1

1、功能说明

用于以树状图形式列出目录内容。包括所有文件、子目录及子目录里的目录和文件

2、语法格式

cd [选项] [目录]

3、选项解释

-a  # 显示所有文件和目录。
-d  # 显示目录名称而非文件。  
-f  # 显示每个文件的全路径名称。
-i  # 不以阶梯状列出文件和目录名称。
-L level # 限制目录显示层级。
-F  # 在执行文件,目录,Socket,符号连接,管道名称名称,各自加上"*","/","@","|"号。
-l  # 如遇到性质为符号连接的目录,直接列出该连接所指向的原始目录。
-p  # 列出权限标示。
-s  # 列出文件和目录大小。

4、参考实例

  • 显示所有文件和目录
[root@xiaonong] tree -a
.
├── bash.sh
├── device_list.sh
├── no_pass_login.sh
├── test
│   ├── test.txt
│   └── test2.txt
├── v2_jump.sh
  • 显示目录名称而非文件
[root@xiaonong] tree -d
.
└── test
  • 显示每个文件的全路径名称
[root@xiaonong] tree -f
.
├── ./bash.sh
├── ./device_list.sh
├── ./no_pass_login.sh
├── ./test
│   ├── ./test/test.txt
│   └── ./test/test2.txt
├── ./v2_jump.sh
  • 不以阶梯状列出文件和目录名称
[root@xiaonong] tree -i
.
bash.sh
device_list.sh
no_pass_login.sh
test
test.txt
test2.txt
v2_jump.sh
  • 限制目录显示层级
[root@xiaonong] tree -L 1
.
├── bash.sh
├── device_list.sh
├── no_pass_login.sh
├── test  
├── v2_jump.sh
  • 对执行位置增加特定字符
[root@xiaonong] tree -F
.
├── bash.sh*
├── device_list.sh*
├── no_pass_login.sh*
├── test/
│   ├── test.txt
│   └── test2.txt
├── v2_jump.sh*
  • 列出权限标识
[root@xiaonong] tree -p
.
├── [-rwxr--r--]  bash.sh
├── [-rwxr-x---]  device_list.sh
├── [-rwxr-x---]  no_pass_login.sh
├── [drwxr-xr-x]  test
│   ├── [-rw-r--r--]  test.txt
│   └── [-rw-r--r--]  test2.txt
├── [-rwxr--r--]  v2_jump.sh
  • 列出文件和目录大小
[root@xiaonong] tree -s
.
├── [327]  bash.sh
├── [5252]  device_list.sh
├── [238]  no_pass_login.sh
├── [128]  test
│   ├── [0]  test.txt
│   └── [0]  test2.txt
├── [152]  v2_jump.sh

5、补充说明

如果Linux中不支持tree命令,需要安装下。
yum -y install tree
mac: brew install tree

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhggcgbc
系列文章
更多 icon
同类精品
更多 icon
继续加载