$ tree 命令需要自行安裝哼拔。
安裝tree:
mac:
$ brew install tree
centos:
$ yum install tree
獲取幫助文檔:
$ tree --help
usage: tree [-acdfghilnpqrstuvxACDFQNSUX] [-H baseHREF] [-T title ] [-L level [-R]]
[-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
[--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
[--filelimit[=]#] [--si] [--timefmt[=]<f>] [<directory list>]
------- Listing options -------
-a All files are listed.
-d List directories only.
-l Follow symbolic links like directories.
-f Print the full path prefix for each file.
-x Stay on current filesystem only.
-L level Descend only level directories deep.
-R Rerun tree when max dir level reached.
-P pattern List only those files that match the pattern given.
-I pattern Do not list files that match the given pattern.
--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 <f> Print and format time according to the format <f>.
-o filename Output to file instead of stdout.
--du Print directory sizes.
--prune Prune empty directories from the output.
-------- File options ---------
-q Print non-printable characters as '?'.
-N Print non-printable characters as is.
-Q Quote filenames with double quotes.
-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.
#NOTE: 只顯示部分
常用操作:
生成目錄樹槐沼。
舉例:
$ tree
.
├── blueprintexample
│ ├── blueprintexample.py
│ ├── simple_page
│ │ ├── __init__.py
│ │ ├── simple_page.py
│ │ └── templates
│ │ └── pages
│ │ ├── hello.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── world.html
│ └── test_blueprintexample.py
顯示文件大小:
$ tree -sh
.
├── [ 50M] 50M.file
├── [100M] bigfile
├── [1.5M] db_cms2.sql
├── [821K] db_cms.sql
├── [3.6K] index.html
├── [180M] interception_nh.mp4
├── [ 98K] t_news.sql
└── [2.9K] t_video_category.sql
顯示目錄
$ tree -d
.
└── uop
├── approval
├── auth
├── deploy_callback
├── deployment
├── disconf
├── dns
├── item_info
├── __pycache__
├── res_callback
├── resources
├── resource_view
├── static
│ └── docs
├── user
└── workbench
層級(jí)比較多的時(shí)候主穗,顯示指定層級(jí)的目錄
$ tree -L 4
├── server.py
├── start.sh
├── uop
│ ├── static
│ │ └── docs
│ │ ├── api.json
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── index.html
│ │ ├── oauth2-redirect.html
│ │ ├── swagger-ui-bundle.js
│ │ ├── swagger-ui-bundle.js.map
│ │ ├── swagger-ui.css
│ │ ├── swagger-ui.css.map
│ │ ├── swagger-ui.js
│ │ ├── swagger-ui.js.map
│ │ ├── swagger-ui-standalone-preset.js
│ │ └── swagger-ui-standalone-preset.js.map
│ ├── user
│ │ ├── errors.py
擴(kuò)展閱讀:
http://blog.csdn.net/beyondlpf/article/details/6922261