Linux/Ubuntu tree 命令以樹形結構顯示文件夾目錄結構

一、安裝命令工具php

sudo apt-get -y install tree

二、能夠查看關於tree命令的幫助信息node

$ tree --help
usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]]
        [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
        [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
        [--filelimit #] [<directory list>]
  -a            All files are listed.
  -d            List directories only.
  -l            Follow symbolic links like directories.
  -f            Print the full path prefix for each file.
  -i            Don't print indentation lines.
  -q            Print non-printable characters as '?'.
  -N            Print non-printable characters as is.
  -p            Print the protections for each file.
  -u            Displays file owner or UID number.
  -g            Displays file group owner or GID number.
  -s            Print the size in bytes of each file.
  -h            Print the size in a more human readable way.
  -D            Print the date of last modification.
  -F            Appends '/', '=', '*', or '|' as per ls -F.
  -v            Sort files alphanumerically by version.
  -r            Sort files in reverse alphanumeric order.
  -t            Sort files by last modification time.
  -x            Stay on current filesystem only.
  -L level      Descend only level directories deep.

三、使用方法(經常使用)編程

(1) 顯示當前目錄的樹形結構bash

jianbao@jianbao-pc:/www/軟件開發$ tree 
.
├── PPT
│   └── PHP性能監控與優化.pptx
├── 電子書
│   ├── Linux.環境C程序設計.徐誠.掃描版.pdf
│   └── UNIX環境高級編程(中文第三版)_掃描版.pdf
├── 視頻
│   └── PHP_C擴展
│       ├── PHP擴展開發教程.mp4
│       ├── swoole第三節第4部分.mp4
│       ├── swoole視頻教程第3節 swoole服務器的進程_線程模型.mp4
│       └── 其餘
│           ├── swoole-chat第二節第二部分.mp4
│           ├── swoole-chat第二節第三部分.mp4
└── 手冊
    └── php_enhanced_zh.chm

(2) 只查看當前第一級的目錄和文件服務器

$ tree -L 1

(3) 只查看當前第二級的目錄和文件swoole

$ tree -L 2

(4) 只查看當前第N級的目錄和文件工具

$ tree -L N

(5) 把目錄結構信息保存到文本中性能

$ tree -L 2 > /home/php-note.com/tree.txt
相關文章
相關標籤/搜索