1TREE(1)                     General Commands Manual                    TREE(1)
2
3
4

NAME

6       tree - list contents of directories in a tree-like format.
7

SYNOPSIS

9       tree  [-acdfghilnpqrstuvxACDFJQNSUX]  [-L level [-R]] [-H baseHREF] [-T
10       title]  [-o  filename]  [-P   pattern]   [-I   pattern]   [--gitignore]
11       [--matchdirs]   [--metafirst]  [--ignore-case]  [--nolinks]  [--inodes]
12       [--device] [--sort[=]name] [--dirsfirst] [--filesfirst] [--filelimit #]
13       [--si]  [--du]  [--prune]  [--timefmt[=]format]  [--fromfile]  [--info]
14       [--noreport] [--version] [--help] [--] [directory ...]
15
16

DESCRIPTION

18       Tree is a recursive directory listing program that produces a depth in‐
19       dented  listing  of  files,  which  is  colorized  ala dircolors if the
20       LS_COLORS environment variable is set and output is to  tty.   With  no
21       arguments,  tree lists the files in the current directory.  When direc‐
22       tory arguments are given, tree lists all the files  and/or  directories
23       found  in the given directories each in turn.  Upon completion of list‐
24       ing all files/directories found, tree returns the total number of files
25       and/or directories listed.
26
27       By default, when a symbolic link is encountered, the path that the sym‐
28       bolic link refers to is printed after the name of the link in the  for‐
29       mat:
30
31           name -> real-path
32
33       If  the  `-l' option is given and the symbolic link refers to an actual
34       directory, then tree will follow the path of the symbolic link as if it
35       were a real directory.
36
37

OPTIONS

39       Tree understands the following command line switches:
40
41

LISTING OPTIONS

43       -a     All  files  are  printed.  By default tree does not print hidden
44              files (those beginning with a dot `.').  In no event  does  tree
45              print  the  file  system  constructs `.' (current directory) and
46              `..' (previous directory).
47
48       -d     List directories only.
49
50       -l     Follows symbolic links if they point to directories, as if  they
51              were  directories.  Symbolic links that will result in recursion
52              are avoided when detected.
53
54       -f     Prints the full path prefix for each file.
55
56       -x     Stay on the current file-system only.  Ala find -xdev.
57
58       -L level
59              Max display depth of the directory tree.
60
61       -R     Recursively cross down the tree each level directories  (see  -L
62              option),  and  at  each  of  them  execute tree again adding `-o
63              00Tree.html' as a new option.
64
65       -P pattern
66              List only those files that match the wild-card pattern.  You may
67              have  multiple  -P  options. Note: you must use the -a option to
68              also consider those files beginning with a dot `.' for matching.
69              Valid  wildcard operators are `*' (any zero or more characters),
70              `**` (any zero or more characters as well as null /'s, i.e. /**/
71              may  match a single /), `?' (any single character), `[...]' (any
72              single character listed between brackets (optional - (dash)  for
73              character  range may be used: ex: [A-Z]), and `[^...]' (any sin‐
74              gle character not listed in brackets) and `|'  separates  alter‐
75              nate  patterns. A '/' at the end of the pattern matches directo‐
76              ries, but not files.
77
78       -I pattern
79              Do not list those files that match the wild-card  pattern.   You
80              may  have  multiple -I options.  See -P above for information on
81              wildcard patterns.
82
83       --gitignore
84              Uses git .gitignore files for filtering files  and  directories.
85              Also uses $GIT_DIR/info/exclude if present.
86
87       --ignore-case
88              If  a  match  pattern  is specified by the -P or -I option, this
89              will cause the pattern to match without regards to the  case  of
90              each letter.
91
92       --matchdirs
93              If  a  match  pattern  is  specified by the -P option, this will
94              cause the pattern to be applied to directory names (in  addition
95              to  filenames).   In the event of a match on the directory name,
96              matching is  disabled  for  the  directory's  contents.  If  the
97              --prune  option  is  used,  empty folders that match the pattern
98              will not be pruned.
99
100       --metafirst
101              Print the meta-data information at the  beginning  of  the  line
102              rather than after the indentation lines.
103
104       --prune
105              Makes  tree prune empty directories from the output, useful when
106              used in conjunction with -P or -I.  See BUGS AND NOTES below for
107              more information on this option.
108
109       --info Prints  file comments found in .info files.  See .INFO FILES be‐
110              low for more information on the format of .info files.
111
112       --noreport
113              Omits printing of the file and directory report at  the  end  of
114              the tree listing.
115
116       --charset charset
117              Set  the  character set to use when outputting HTML and for line
118              drawing.
119
120       --filelimit #
121              Do not descend directories that contain more than # entries.
122
123       --timefmt format
124              Prints (implies -D) and formats the date according to the format
125              string which uses the strftime(3) syntax.
126
127       -o filename
128              Send output to filename.
129

FILE OPTIONS

131       -q     Print  non-printable  characters  in filenames as question marks
132              instead of the default.
133
134       -N     Print non-printable characters as is instead of as escaped octal
135              numbers.
136
137       -Q     Quote the names of files in double quotes.
138
139       -p     Print  the  file  type  and permissions for each file (as per ls
140              -l).
141
142       -u     Print the username, or UID # if no username is available, of the
143              file.
144
145       -g     Print the group name, or GID # if no group name is available, of
146              the file.
147
148       -s     Print the size of each file in bytes along with the name.
149
150       -h     Print the size of each file but in a more  human  readable  way,
151              e.g.  appending  a size letter for kilobytes (K), megabytes (M),
152              gigabytes (G), terabytes (T), petabytes (P) and exabytes (E).
153
154       --si   Like -h but use SI units (powers of 1000) instead.
155
156       --du   For each directory report its size as the accumulation of  sizes
157              of  all  its  files and sub-directories (and their files, and so
158              on).  The total amount of used space is also given in the  final
159              report  (like the 'du -c' command.) This option requires tree to
160              read the entire directory tree before emitting it, see BUGS  AND
161              NOTES below.  Implies -s.
162
163       -D     Print  the  date of the last modification time or if -c is used,
164              the last status change time for the file listed.
165
166       -F     Append a `/' for directories, a `=' for socket files, a `*'  for
167              executable  files,  a  `>'  for  doors  (Solaris)  and a `|' for
168              FIFO's, as per ls -F
169
170       --inodes
171              Prints the inode number of the file or directory
172
173       --device
174              Prints the device number to which the file or directory belongs
175

SORTING OPTIONS

177       -v     Sort the output by version.
178
179       -t     Sort the output by last modification time instead of  alphabeti‐
180              cally.
181
182       -c     Sort the output by last status change instead of alphabetically.
183              Modifies the -D option (if used) to print the last status change
184              instead of modification time.
185
186       -U     Do  not  sort.  Lists files in directory order. Disables --dirs‐
187              first.
188
189       -r     Sort the output in reverse order.  This is a meta-sort that  al‐
190              ter the above sorts.  This option is disabled when -U is used.
191
192       --dirsfirst
193              List  directories  before files. This is a meta-sort that alters
194              the above sorts.  This option is disabled when -U is used.
195
196       --filesfirst
197              List files before directories. This is a meta-sort  that  alters
198              the above sorts.  This option is disabled when -U is used.
199
200       --sort[=]type
201              Sort  the  output  by type instead of name. Possible values are:
202              ctime (-c), mtime (-t), size, or version (-v).
203
204

GRAPHICS OPTIONS

206       -i     Makes tree not print the indentation lines, useful when used  in
207              conjunction with the -f option.  Also removes as much whitespace
208              as possible when used with the -J or -x options.
209
210       -A     Turn on ANSI line graphics hack when  printing  the  indentation
211              lines.
212
213       -S     Turn  on  CP437  line  graphics (useful when using Linux console
214              mode fonts). This option is now equivalent to `--charset=IBM437'
215              and may eventually be depreciated.
216
217       -n     Turn colorization off always, over-ridden by the -C option, how‐
218              ever overrides CLICOLOR_FORCE if present.
219
220       -C     Turn colorization on always, using built-in  color  defaults  if
221              the  LS_COLORS or TREE_COLORS environment variables are not set.
222              Useful to colorize output to a pipe.
223

XML/JSON/HTML OPTIONS

225       -X     Turn on XML output. Outputs the directory tree as an XML format‐
226              ted file.
227
228       -J     Turn  on  JSON output. Outputs the directory tree as a JSON for‐
229              matted array.
230
231       -H baseHREF
232              Turn on HTML output, including HTTP references. Useful  for  ftp
233              sites.   baseHREF  gives  the  base ftp location when using HTML
234              output. That is, the local directory  may  be  `/local/ftp/pub',
235              but  it  must  be referenced as `ftp://hostname.organization.do‐
236              main/pub' (baseHREF should  be  `ftp://hostname.organization.do‐
237              main').  Hint:  don't use ANSI lines with this option, and don't
238              give more than one directory in the directory list. If you  wish
239              to use colors via CSS style-sheet, use the -C option in addition
240              to this option to force color output.
241
242       -T title
243              Sets the title and H1 header string in HTML output mode.
244
245       --nolinks
246              Turns off hyperlinks in HTML output.
247

INPUT OPTIONS

249       --fromfile Reads a directory listing from a file rather than the  file-
250       system.   Paths  provided  on  the  command line are files to read from
251       rather than directories to search.  The  dot  (.)  directory  indicates
252       that  tree  should  read  paths from standard input. NOTE: this is only
253       suitable for reading the output of a program such as  find,  not  'tree
254       -fi'  as  symlinks cannot (at least as yet) be distinguished from files
255       that simply contain ' -> ' as part of the filename.
256
257

MISC OPTIONS

259       --help Outputs a verbose usage listing.
260
261       --version
262              Outputs the version of tree.
263
264       --     Option processing terminator.  No further options will  be  pro‐
265              cessed after this.
266

.INFO FILES

268       .info  files are similiar to .gitignore files, if a .info file is found
269       while scanning a directory it is read and added to a stack of .info in‐
270       formation.  Each file is composed of comments (lines starting with hash
271       marks (#),) or wild-card patterns which may match a  file  relative  to
272       the  directory  the  .info  file is found in.  If a file should match a
273       pattern, the tab indented comment that follows the pattern is  used  as
274       the  file comment.  A comment is terminated by a non-tab indented line.
275       Multiple patterns, each to a line, may share the same comment.
276
277

FILES

279       /etc/DIR_COLORS          System color database.
280       ~/.dircolors             Users color database.
281       .gitignore               Git exclusion file
282       $GIT_DIR/info/exclude    Global git file exclusion list
283       .info                    File comment file
284       /usr/share/finfo/global_info  Global file comment file
285
286
287

ENVIRONMENT

289       LS_COLORS      Color information created by dircolors
290       TREE_COLORS    Uses this for color information over LS_COLORS if it  is
291       set.
292       TREE_CHARSET   Character set for tree to use in HTML mode.
293       CLICOLOR       Enables colorization even if TREE_COLORS or LS_COLORS is
294       not set.
295       CLICOLOR_FORCE Always enables colorization (effectively -C)
296       LC_CTYPE       Locale for filename output.
297       LC_TIME        Locale for timefmt output, see strftime(3).
298       TZ             Timezone for timefmt output, see strftime(3).
299       STDDATA_FD     Enable the stddata feature, optionally set descriptor to
300       use.
301
302

AUTHOR

304       Steve Baker (ice@mama.indstate.edu)
305       HTML output hacked by Francesc Rocher (rocher@econ.udg.es)
306       Charsets and OS/2 support by Kyosuke Tokoro (NBG01720@nifty.ne.jp)
307
308

BUGS AND NOTES

310       Tree  does not prune "empty" directories when the -P and -I options are
311       used by default. Use the --prune option.
312
313       The -h and --si options round to the nearest whole number unlike the ls
314       implementations which rounds up always.
315
316       Pruning  files  and directories with the -I, -P and --filelimit options
317       will lead to incorrect file/directory count reports.
318
319       The --prune and --du options cause tree to accumulate the  entire  tree
320       in  memory before emitting it. For large directory trees this can cause
321       a significant delay in output and the use of large amounts of memory.
322
323       The timefmt expansion buffer is limited to  a  ridiculously  large  255
324       characters.  Output of time strings longer than this will be undefined,
325       but are guaranteed to not exceed 255 characters.
326
327       XML/JSON trees are not colored, which is a bit of a shame.
328
329       Probably more.
330
331       As of version 2.0.0, in Linux, tree will attempt to automatically  out‐
332       put  a compact JSON tree on file descriptor 3 (what I call stddata,) if
333       present and the environment variable STDDATA_FD is defined or set to  a
334       positive  non-zero  file  descriptor  value to use to output on.  It is
335       hoped that some day a better Linux/Unix shell  may  take  advantage  of
336       this feature, though BSON would probably be a better format for this.
337
338

SEE ALSO

340       dircolors(1), ls(1), find(1), du(1), strftime(3) gitignore(5)
341
342
343
344Tree 2.0.0                                                             TREE(1)
Impressum