1TREE(1) General Commands Manual TREE(1)
2
3
4
6 tree - list contents of directories in a tree-like format.
7
9 tree [-acdfghilnpqrstuvxACDFJQNSUX] [-L level [-R]] [-H baseHREF] [-T
10 title] [-o filename] [-P pattern] [-I pattern] [--gitignore] [--git‐
11 file[=]file] [--matchdirs] [--metafirst] [--ignore-case] [--nolinks]
12 [--hintro[=]file] [--houtro[=]file] [--inodes] [--device]
13 [--sort[=]name] [--dirsfirst] [--filesfirst] [--filelimit #] [--si]
14 [--du] [--prune] [--charset[=]X] [--timefmt[=]format] [--fromfile]
15 [--fflinks] [--info] [--infofile[=]file] [--noreport] [--version]
16 [--help] [--] [directory ...]
17
18
20 Tree is a recursive directory listing program that produces a depth in‐
21 dented listing of files, which is colorized ala dircolors if the
22 LS_COLORS environment variable is set and output is to tty. With no
23 arguments, tree lists the files in the current directory. When direc‐
24 tory arguments are given, tree lists all the files and/or directories
25 found in the given directories each in turn. Upon completion of list‐
26 ing all files/directories found, tree returns the total number of files
27 and/or directories listed.
28
29 By default, when a symbolic link is encountered, the path that the sym‐
30 bolic link refers to is printed after the name of the link in the for‐
31 mat:
32
33 name -> real-path
34
35 If the `-l' option is given and the symbolic link refers to an actual
36 directory, then tree will follow the path of the symbolic link as if it
37 were a real directory.
38
39
41 Tree understands the following command line switches:
42
43
45 -a All files are printed. By default tree does not print hidden
46 files (those beginning with a dot `.'). In no event does tree
47 print the file system constructs `.' (current directory) and
48 `..' (previous directory).
49
50 -d List directories only.
51
52 -l Follows symbolic links if they point to directories, as if they
53 were directories. Symbolic links that will result in recursion
54 are avoided when detected.
55
56 -f Prints the full path prefix for each file.
57
58 -x Stay on the current file-system only. Ala find -xdev.
59
60 -L level
61 Max display depth of the directory tree.
62
63 -R Recursively cross down the tree each level directories (see -L
64 option), and at each level outputting to a file named
65 00Tree.html (ala -o).
66
67 -P pattern
68 List only those files that match the wild-card pattern. You may
69 have multiple -P options. Note: you must use the -a option to
70 also consider those files beginning with a dot `.' for matching.
71 Valid wildcard operators are `*' (any zero or more characters),
72 `**` (any zero or more characters as well as null /'s, i.e. /**/
73 may match a single /), `?' (any single character), `[...]' (any
74 single character listed between brackets (optional - (dash) for
75 character range may be used: ex: [A-Z]), and `[^...]' (any sin‐
76 gle character not listed in brackets) and `|' separates alter‐
77 nate patterns. A '/' at the end of the pattern matches directo‐
78 ries, but not files.
79
80 -I pattern
81 Do not list those files that match the wild-card pattern. You
82 may have multiple -I options. See -P above for information on
83 wildcard patterns.
84
85 --gitignore
86 Uses git .gitignore files for filtering files and directories.
87 Also uses $GIT_DIR/info/exclude if present.
88
89 --gitfile[=]file
90 Use file explicitly as a gitignore file.
91
92 --ignore-case
93 If a match pattern is specified by the -P or -I option, this
94 will cause the pattern to match without regard to the case of
95 each letter.
96
97 --matchdirs
98 If a match pattern is specified by the -P option, this will
99 cause the pattern to be applied to directory names (in addition
100 to filenames). In the event of a match on the directory name,
101 matching is disabled for the directory's contents. If the
102 --prune option is used, empty folders that match the pattern
103 will not be pruned.
104
105 --metafirst
106 Print the meta-data information at the beginning of the line
107 rather than after the indentation lines.
108
109 --prune
110 Makes tree prune empty directories from the output, useful when
111 used in conjunction with -P or -I. See BUGS AND NOTES below for
112 more information on this option.
113
114 --info Prints file comments found in .info files. See .INFO FILES be‐
115 low for more information on the format of .info files.
116
117 --infofile[=]file
118 Use file explicitly as a info file.
119
120 --noreport
121 Omits printing of the file and directory report at the end of
122 the tree listing.
123
124 --charset[=]charset
125 Set the character set to use when outputting HTML and for line
126 drawing.
127
128 --filelimit[=]#
129 Do not descend directories that contain more than # entries.
130
131 --timefmt[=]format
132 Prints (implies -D) and formats the date according to the format
133 string which uses the strftime(3) syntax.
134
135 -o filename
136 Send output to filename.
137
139 -q Print non-printable characters in filenames as question marks
140 instead of the default.
141
142 -N Print non-printable characters as is instead of as escaped octal
143 numbers.
144
145 -Q Quote the names of files in double quotes.
146
147 -p Print the file type and permissions for each file (as per ls
148 -l).
149
150 -u Print the username, or UID # if no username is available, of the
151 file.
152
153 -g Print the group name, or GID # if no group name is available, of
154 the file.
155
156 -s Print the size of each file in bytes along with the name.
157
158 -h Print the size of each file but in a more human readable way,
159 e.g. appending a size letter for kilobytes (K), megabytes (M),
160 gigabytes (G), terabytes (T), petabytes (P) and exabytes (E).
161
162 --si Like -h but use SI units (powers of 1000) instead.
163
164 --du For each directory report its size as the accumulation of sizes
165 of all its files and sub-directories (and their files, and so
166 on). The total amount of used space is also given in the final
167 report (like the 'du -c' command.) This option requires tree to
168 read the entire directory tree before emitting it, see BUGS AND
169 NOTES below. Implies -s.
170
171 -D Print the date of the last modification time or if -c is used,
172 the last status change time for the file listed.
173
174 -F Append a `/' for directories, a `=' for socket files, a `*' for
175 executable files, a `>' for doors (Solaris) and a `|' for
176 FIFO's, as per ls -F
177
178 --inodes
179 Prints the inode number of the file or directory
180
181 --device
182 Prints the device number to which the file or directory belongs
183
185 -v Sort the output by version.
186
187 -t Sort the output by last modification time instead of alphabeti‐
188 cally.
189
190 -c Sort the output by last status change instead of alphabetically.
191 Modifies the -D option (if used) to print the last status change
192 instead of modification time.
193
194 -U Do not sort. Lists files in directory order. Disables --dirs‐
195 first.
196
197 -r Sort the output in reverse order. This is a meta-sort that al‐
198 ter the above sorts. This option is disabled when -U is used.
199
200 --dirsfirst
201 List directories before files. This is a meta-sort that alters
202 the above sorts. This option is disabled when -U is used.
203
204 --filesfirst
205 List files before directories. This is a meta-sort that alters
206 the above sorts. This option is disabled when -U is used.
207
208 --sort[=]type
209 Sort the output by type instead of name. Possible values are:
210 ctime (-c), mtime (-t), size, or version (-v).
211
212
214 -i Makes tree not print the indentation lines, useful when used in
215 conjunction with the -f option. Also removes as much whitespace
216 as possible when used with the -J or -X options.
217
218 -A Turn on ANSI line graphics hack when printing the indentation
219 lines.
220
221 -S Turn on CP437 line graphics (useful when using Linux console
222 mode fonts). This option is now equivalent to `--charset=IBM437'
223 and may eventually be depreciated.
224
225 -n Turn colorization off always, over-ridden by the -C option, how‐
226 ever overrides CLICOLOR_FORCE if present.
227
228 -C Turn colorization on always, using built-in color defaults if
229 the LS_COLORS or TREE_COLORS environment variables are not set.
230 Useful to colorize output to a pipe.
231
233 -X Turn on XML output. Outputs the directory tree as an XML format‐
234 ted file.
235
236 -J Turn on JSON output. Outputs the directory tree as a JSON for‐
237 matted array.
238
239 -H baseHREF
240 Turn on HTML output, including HTTP references. Useful for ftp
241 sites. baseHREF gives the base ftp location when using HTML
242 output. That is, the local directory may be `/local/ftp/pub',
243 but it must be referenced as `ftp://hostname.organization.do‐
244 main/pub' (baseHREF should be `ftp://hostname.organization.do‐
245 main'). Hint: don't use ANSI lines with this option, and don't
246 give more than one directory in the directory list. If you wish
247 to use colors via CSS style-sheet, use the -C option in addition
248 to this option to force color output.
249
250 --hintro[=]file
251 Use file as the HTML intro in place of the default one. Use an
252 empty file or /dev/null to eliminate the intro altogether.
253
254 --houtro[=]file
255 Use file as the HTML outro in place of the default one. Use an
256 empty file or /dev/null to eliminate the outro altogether.
257
258 -T title
259 Sets the title and H1 header string in HTML output mode.
260
261 --nolinks
262 Turns off hyperlinks in HTML output.
263
265 --fromfile
266 Reads a directory listing from a file rather than the file-sys‐
267 tem. Paths provided on the command line are files to read from
268 rather than directories to search. The dot (.) directory indi‐
269 cates that tree should read paths from standard input. NOTE:
270 this is only suitable for reading the output of a program such
271 as find, not 'tree -fi' as symlinks are not distinguished from
272 files that simply contain ' -> ' as part of the filename unless
273 the --fflinks option is used.
274
275 --fflinks
276 Processes symbolic link information found in a file, as from the
277 output of 'tree -fi --noreport'. Only the first occurrence of
278 the string ' -> ' is used to denote the separation of the file‐
279 name from the link.
280
282 --help Outputs a verbose usage listing.
283
284 --version
285 Outputs the version of tree.
286
287 -- Option processing terminator. No further options will be pro‐
288 cessed after this.
289
291 .info files are similiar to .gitignore files, if a .info file is found
292 while scanning a directory it is read and added to a stack of .info in‐
293 formation. Each file is composed of comments (lines starting with hash
294 marks (#),) or wild-card patterns which may match a file relative to
295 the directory the .info file is found in. If a file should match a
296 pattern, the tab indented comment that follows the pattern is used as
297 the file comment. A comment is terminated by a non-tab indented line.
298 Multiple patterns, each to a line, may share the same comment.
299
300
302 /etc/DIR_COLORS System color database.
303 ~/.dircolors Users color database.
304 .gitignore Git exclusion file
305 $GIT_DIR/info/exclude Global git file exclusion list
306 .info File comment file
307 /usr/share/finfo/global_info Global file comment file
308
309
310
312 LS_COLORS Color information created by dircolors
313 TREE_COLORS Uses this for color information over LS_COLORS if it is
314 set.
315 TREE_CHARSET Character set for tree to use in HTML mode.
316 CLICOLOR Enables colorization even if TREE_COLORS or LS_COLORS is
317 not set.
318 CLICOLOR_FORCE Always enables colorization (effectively -C)
319 NO_COLOR Disable colorization (effectively -n) (see https://no-
320 color.org/)
321 LC_CTYPE Locale for filename output.
322 LC_TIME Locale for timefmt output, see strftime(3).
323 TZ Timezone for timefmt output, see strftime(3).
324 STDDATA_FD Enable the stddata feature, optionally set descriptor to
325 use.
326
327
329 Steve Baker (ice@mama.indstate.edu)
330 HTML output hacked by Francesc Rocher (rocher@econ.udg.es)
331 Charsets and OS/2 support by Kyosuke Tokoro (NBG01720@nifty.ne.jp)
332
333
335 Tree does not prune "empty" directories when the -P and -I options are
336 used by default. Use the --prune option.
337
338 The -h and --si options round to the nearest whole number unlike the ls
339 implementations which rounds up always.
340
341 Pruning files and directories with the -I, -P and --filelimit options
342 will lead to incorrect file/directory count reports.
343
344 The --prune and --du options cause tree to accumulate the entire tree
345 in memory before emitting it. For large directory trees this can cause
346 a significant delay in output and the use of large amounts of memory.
347
348 The timefmt expansion buffer is limited to a ridiculously large 255
349 characters. Output of time strings longer than this will be undefined,
350 but are guaranteed to not exceed 255 characters.
351
352 XML/JSON trees are not colored, which is a bit of a shame.
353
354 Probably more.
355
356 As of version 2.0.0, in Linux, tree will attempt to automatically out‐
357 put a compact JSON tree on file descriptor 3 (what I call stddata,) if
358 present and the environment variable STDDATA_FD is defined or set to a
359 positive non-zero file descriptor value to use to output on. It is
360 hoped that some day a better Linux/Unix shell may take advantage of
361 this feature, though BSON would probably be a better format for this.
362
363
365 dircolors(1), ls(1), find(1), du(1), strftime(3) gitignore(5)
366
367
368
369Tree 2.1.0 TREE(1)