首页 > 代码库 > linux -- tree 命令

linux -- 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.       #显示N层目录
  -R            Rerun tree when max dir level reached.
  -P pattern    List only those files that match the pattern given.  #只显示符合"pattern"的文件或目录名称
  -I pattern    Do not list files that match the given pattern.    #不显示符合范本样式的文件或目录名称 tree -I "*.c"
  --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.
  -------- 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.
  --si          Like -h, but use in SI units (powers of 1000).
  -D            Print the date of last modification or (-c) status change.    #列出文件或目录的更改时间
  -F            Appends ‘/‘, ‘=‘, ‘*‘, ‘@‘, ‘|‘ or ‘>‘ as per ls -F.
  --inodes      Print inode number of each file.
  --device      Print device ID number to which each file belongs.
  ------- Sorting options -------
  -v            Sort files alphanumerically by version.     #按字母数字排序
  -r            Sort files in reverse alphanumeric order.  #按字母数字倒序排序
  -t            Sort files by last modification time.            # 按最后修改时间排序的文件
  -c            Sort files by last status change time.         # 按最近的修改状态排序
  -U            Leave files unsorted.                                 #分类整理排序
  --dirsfirst   List directories before files (-U disables).
  ------- Graphics options ------
  -i            Don‘t print indentation lines.  #不以阶梯状列出文件或目录名称
  -A            Print ANSI lines graphic indentation lines.   #使用ASNI绘图字符显示树状图而非以ASCII字符组合
  -S            Print with ASCII graphics indentation lines.
  -n            Turn colorization off always (-C overrides).  #不在文件和目录清单加上色彩
  -C            Turn colorization on always.         #在文件和目录清单加上色彩,便于区分各种类型
  ------- XML/HTML options -------
  -X            Prints out an XML representation of the tree.
  -H baseHREF   Prints out HTML format with baseHREF as top directory.
  -T string     Replace the default HTML title and H1 header with string.
  --nolinks     Turn off hyperlinks in HTML output.
  ---- Miscellaneous options ----
  --version     Print version and exit.
  --help         Print usage and this help message and exit.