1TREE(1) General Commands Manual TREE(1)
2
3
4
6 tree - list contents of directories in a tree-like format.
7
9 tree [-acdfghilnpqrstuvxACDFQNSUX] [-L level [-R]] [-H baseHREF] [-T
10 title] [-o filename] [--nolinks] [-P pattern] [-I pattern] [--inodes]
11 [--device] [--noreport] [--dirsfirst] [--version] [--help] [--filelimit
12 #] [--si] [--prune] [--du] [--timefmt format] [--matchdirs] [--]
13 [directory ...]
14
15
17 Tree is a recursive directory listing program that produces a depth
18 indented listing of files, which is colorized ala dircolors if the
19 LS_COLORS environment variable is set and output is to tty. With no
20 arguments, tree lists the files in the current directory. When direc‐
21 tory arguments are given, tree lists all the files and/or directories
22 found in the given directories each in turn. Upon completion of list‐
23 ing all files/directories found, tree returns the total number of files
24 and/or directories listed.
25
26 By default, when a symbolic link is encountered, the path that the sym‐
27 bolic link refers to is printed after the name of the link in the for‐
28 mat:
29
30 name -> real-path
31
32 If the `-l' option is given and the symbolic link refers to an actual
33 directory, then tree will follow the path of the symbolic link as if it
34 were a real directory.
35
36
38 Tree understands the following command line switches:
39
40
42 -a All files are printed. By default tree does not print hidden
43 files (those beginning with a dot `.'). In no event does tree
44 print the file system constructs `.' (current directory) and
45 `..' (previous directory).
46
47 -d List directories only.
48
49 -l Follows symbolic links if they point to directories, as if they
50 were directories. Symbolic links that will result in recursion
51 are avoided when detected.
52
53 -f Prints the full path prefix for each file.
54
55 -x Stay on the current file-system only. Ala find -xdev.
56
57 -L level
58 Max display depth of the directory tree.
59
60 -R Recursively cross down the tree each level directories (see -L
61 option), and at each of them execute tree again adding `-o
62 00Tree.html' as a new option.
63
64 -P pattern
65 List only those files that match the wild-card pattern. Note:
66 you must use the -a option to also consider those files begin‐
67 ning with a dot `.' for matching. Valid wildcard operators are
68 `*' (any zero or more characters), `?' (any single character),
69 `[...]' (any single character listed between brackets (optional
70 - (dash) for character range may be used: ex: [A-Z]), and
71 `[^...]' (any single character not listed in brackets) and `|'
72 separates alternate patterns.
73
74 -I pattern
75 Do not list those files that match the wild-card pattern.
76
77 .TP --ignore-case If a match pattern is specified by the -P or -I
78 option, this will cause the pattern to match without regards to the
79 case of each letter.
80
81 --matchdirs
82 If a match pattern is specified by the -P option, this will
83 cause the pattern to be applied to directory names (in addition
84 to filenames). In the event of a match on the directory name,
85 matching is disabled for the directory's contents. If the
86 --prune option is used, empty folders that match the pattern
87 will not be pruned.
88
89 --prune
90 Makes tree prune empty directories from the output, useful when
91 used in conjunction with -P or -I. See BUGS AND NOTES below for
92 more information on this option.
93
94 --noreport
95 Omits printing of the file and directory report at the end of
96 the tree listing.
97
98 --charset charset
99 Set the character set to use when outputting HTML and for line
100 drawing.
101
102 --filelimit #
103 Do not descend directories that contain more than # entries.
104
105 --timefmt format
106 Prints (implies -D) and formats the date according to the format
107 string which uses the strftime(3) syntax.
108
109 -o filename
110 Send output to filename.
111
113 -q Print non-printable characters in filenames as question marks
114 instead of the default.
115
116 -N Print non-printable characters as is instead of as escaped octal
117 numbers.
118
119 -Q Quote the names of files in double quotes.
120
121 -p Print the file type and permissions for each file (as per ls
122 -l).
123
124 -u Print the username, or UID # if no username is available, of the
125 file.
126
127 -g Print the group name, or GID # if no group name is available, of
128 the file.
129
130 -s Print the size of each file in bytes along with the name.
131
132 -h Print the size of each file but in a more human readable way,
133 e.g. appending a size letter for kilobytes (K), megabytes (M),
134 gigabytes (G), terabytes (T), petabytes (P) and exabytes (E).
135
136 --si Like -h but use SI units (powers of 1000) instead.
137
138 --du For each directory report its size as the accumulation of sizes
139 of all its files and sub-directories (and their files, and so
140 on). The total amount of used space is also given in the final
141 report (like the 'du -c' command.) This option requires tree to
142 read the entire directory tree before emitting it, see BUGS AND
143 NOTES below. Implies -s.
144
145 -D Print the date of the last modification time or if -c is used,
146 the last status change time for the file listed.
147
148 -F Append a `/' for directories, a `=' for socket files, a `*' for
149 executable files, a `>' for doors (Solaris) and a `|' for
150 FIFO's, as per ls -F
151
152 --inodes
153 Prints the inode number of the file or directory
154
155 --device
156 Prints the device number to which the file or directory belongs
157
159 -v Sort the output by version.
160
161 -t Sort the output by last modification time instead of alphabeti‐
162 cally.
163
164 -c Sort the output by last status change instead of alphabetically.
165 Modifies the -D option (if used) to print the last status change
166 instead of modification time.
167
168 -U Do not sort. Lists files in directory order. Disables --dirs‐
169 first.
170
171 -r Sort the output in reverse order. This is a meta-sort that
172 alter the above sorts. This option is disabled when -U is used.
173
174 --dirsfirst
175 List directories before files. This is a meta-sort that alters
176 the above sorts. This option is disabled when -U is used.
177
178 --sort[=]<name>
179 Sort the output by name (as per ls): name (default), ctime (-c),
180 mtime (-t), size or version (-v).
181
183 -i Makes tree not print the indentation lines, useful when used in
184 conjunction with the -f option. Also removes as much whitespace
185 as possible when used with the -J or -x options.
186
187 -A Turn on ANSI line graphics hack when printing the indentation
188 lines.
189
190 -S Turn on CP437 line graphics (useful when using Linux console
191 mode fonts). This option is now equivalent to `--charset=IBM437'
192 and may eventually be depreciated.
193
194 -n Turn colorization off always, over-ridden by the -C option.
195
196 -C Turn colorization on always, using built-in color defaults if
197 the LS_COLORS environment variable is not set. Useful to col‐
198 orize output to a pipe.
199
201 -X Turn on XML output. Outputs the directory tree as an XML format‐
202 ted file.
203
204 -J Turn on JSON output. Outputs the directory tree as an JSON for‐
205 matted array.
206
207 -H baseHREF
208 Turn on HTML output, including HTTP references. Useful for ftp
209 sites. baseHREF gives the base ftp location when using HTML
210 output. That is, the local directory may be `/local/ftp/pub',
211 but it must be referenced as `ftp://hostname.organiza‐
212 tion.domain/pub' (baseHREF should be `ftp://hostname.organiza‐
213 tion.domain'). Hint: don't use ANSI lines with this option, and
214 don't give more than one directory in the directory list. If you
215 wish to use colors via CCS style-sheet, use the -C option in
216 addition to this option to force color output.
217
218 -T title
219 Sets the title and H1 header string in HTML output mode.
220
221 --nolinks
222 Turns off hyperlinks in HTML output.
223
225 --help Outputs a verbose usage listing.
226
227 --version
228 Outputs the version of tree.
229
230 -- Option processing terminator. No further options will be pro‐
231 cessed after this.
232
234 /etc/DIR_COLORS System color database.
235 ~/.dircolors Users color database.
236
237
239 LS_COLORS Color information created by dircolors
240 TREE_COLORS Uses this for color information over LS_COLORS if it is
241 set.
242 TREE_CHARSET Character set for tree to use in HTML mode.
243 LC_CTYPE Locale for filename output.
244 LC_TIME Locale for timefmt output, see strftime(3).
245 TZ Timezone for timefmt output, see strftime(3).
246
247
249 Steve Baker (ice@mama.indstate.edu)
250 HTML output hacked by Francesc Rocher (rocher@econ.udg.es)
251 Charsets and OS/2 support by Kyosuke Tokoro (NBG01720@nifty.ne.jp)
252
253
255 Tree does not prune "empty" directories when the -P and -I options are
256 used by default. Use the --prune option.
257
258 The -h and --si options round to the nearest whole number unlike the ls
259 implementations which rounds up always.
260
261 Pruning files and directories with the -I, -P and --filelimit options
262 will lead to incorrect file/directory count reports.
263
264 The --prune and --du options cause tree to accumulate the entire tree
265 in memory before emitting it. For large directory trees this can cause
266 a significant delay in output and the use of large amounts of memory.
267
268 The timefmt expansion buffer is limited to a ridiculously large 255
269 characters. Output of time strings longer than this will be undefined,
270 but are guaranteed to not exceed 255 characters.
271
272 XML/JSON trees are not colored, which is a bit of a shame.
273
274 Probably more.
275
276
278 dircolors(1), ls(1), find(1), du(1), strftime(3)
279
280
281
282Tree 1.7.0 TREE(1)