man-pages/man1/tree.1.html
2021-03-31 01:06:50 +01:00

662 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of TREE</TITLE>
</HEAD><BODY>
<H1>TREE</H1>
Section: User Commands (1)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
tree - list contents of directories in a tree-like format.
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>tree</B> [<B>-acdfghilnpqrstuvxACDFQNSUX</B>] [<B>-L</B> <I>level</I> [<B>-R</B>]] [<B>-H</B> <I>baseHREF</I>] [<B>-T</B> <I>title</I>] [<B>-o</B> <I>filename</I>] [<B>--nolinks</B>] [<B>-P</B> <I>pattern</I>] [<B>-I</B> <I>pattern</I>] [<B>--inodes</B>] [<B>--device</B>] [<B>--noreport</B>] [<B>--dirsfirst</B>] [<B>--version</B>] [<B>--help</B>] [<B>--filelimit</B> <I>#</I>] [<B>--si</B>] [<B>--prune</B>] [<B>--du</B>] [<B>--timefmt</B> <I>format</I>] [<B>--matchdirs</B>] [<B>--fromfile</B>] [<B>--</B>] [<I>directory</I> ...]
<P>
<BR>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<I>Tree</I> is a recursive directory listing program that produces a depth
indented listing of files, which is colorized ala <I>dircolors</I> if the
<B>LS_COLORS</B> environment variable is set and output is to tty. With no
arguments, <I>tree</I> lists the files in the current directory. When directory
arguments are given, <I>tree</I> lists all the files and/or directories found in
the given directories each in turn. Upon completion of listing all
files/directories found, <I>tree</I> returns the total number of files and/or
directories listed.
<P>
By default, when a symbolic link is encountered, the path that the symbolic
link refers to is printed after the name of the link in the format:
<BR>
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;-&gt;&nbsp;real-path
<BR>
<P>
If the `<B>-l</B>' option is given and the symbolic link refers to an actual
directory, then <I>tree</I> will follow the path of the symbolic link as if
it were a real directory.
<BR>
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<I>Tree</I> understands the following command line switches:
<P>
<A NAME="lbAF">&nbsp;</A>
<H2>LISTING OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="1"><B>-a</B>
<DD>
All files are printed. By default tree does not print hidden files (those
beginning with a dot `.'). In no event does tree print the file system
constructs `.' (current directory) and `..' (previous directory).
</DL>
<P>
<DL COMPACT>
<DT id="2"><B>-d</B>
<DD>
List directories only.
</DL>
<P>
<DL COMPACT>
<DT id="3"><B>-l</B>
<DD>
Follows symbolic links if they point to directories, as if they were
directories. Symbolic links that will result in recursion are avoided when
detected.
</DL>
<P>
<DL COMPACT>
<DT id="4"><B>-f</B>
<DD>
Prints the full path prefix for each file.
</DL>
<P>
<DL COMPACT>
<DT id="5"><B>-x</B>
<DD>
Stay on the current file-system only. Ala <B>find </B><I>-xdev</I>.
</DL>
<P>
<DL COMPACT>
<DT id="6"><B>-L </B><I>level</I>
<DD>
Max display depth of the directory tree.
</DL>
<P>
<DL COMPACT>
<DT id="7"><B>-R</B>
<DD>
Recursively cross down the tree each <I>level</I> directories (see <B>-L</B>
option), and at each of them execute <B>tree</B> again adding `-o 00Tree.html'
as a new option.
</DL>
<P>
<DL COMPACT>
<DT id="8"><B>-P </B><I>pattern</I>
<DD>
List only those files that match the wild-card <I>pattern</I>. Note: you must
use the <I>-a</I> option to also consider those files beginning with a dot `.'
for matching. Valid wildcard operators are `*' (any zero or more characters),
`?' (any single character), `[...]' (any single character listed between
brackets (optional - (dash) for character range may be used: ex: [A-Z]), and
`[^...]' (any single character not listed in brackets) and `|' separates
alternate patterns.
</DL>
<P>
<DL COMPACT>
<DT id="9"><B>-I </B><I>pattern</I>
<DD>
Do not list those files that match the wild-card <I>pattern</I>.
</DL>
<P>
<DL COMPACT>
<DT id="10"><B>--ignore-case</B>
<DD>
If a match pattern is specified by the <B>-P</B> or <B>-I</B> option, this will
cause the pattern to match without regards to the case of each letter.
</DL>
<P>
<DL COMPACT>
<DT id="11"><B>--matchdirs</B>
<DD>
If a match pattern is specified by the <B>-P</B> option, this will cause the
pattern to be applied to directory names (in addition to filenames). In the
event of a match on the directory name, matching is disabled for the directory's
contents. If the <B>--prune</B> option is used, empty folders that match the
pattern will not be pruned.
</DL>
<P>
<DL COMPACT>
<DT id="12"><B>--prune</B>
<DD>
Makes tree prune empty directories from the output, useful when used in
conjunction with <B>-P</B> or <B>-I</B>. See <B>BUGS AND NOTES</B> below for
more information on this option.
</DL>
<P>
<DL COMPACT>
<DT id="13"><B>--noreport</B>
<DD>
Omits printing of the file and directory report at the end of the tree
listing.
</DL>
<P>
<DL COMPACT>
<DT id="14"><B>--charset </B><I>charset</I>
<DD>
Set the character set to use when outputting HTML and for line drawing.
</DL>
<P>
<DL COMPACT>
<DT id="15"><B>--filelimit </B><I>#</I>
<DD>
Do not descend directories that contain more than <I>#</I> entries.
</DL>
<P>
<DL COMPACT>
<DT id="16"><B>--timefmt </B><I>format</I>
<DD>
Prints (implies -D) and formats the date according to the format string
which uses the <B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3) syntax.
</DL>
<P>
<DL COMPACT>
<DT id="17"><B>-o </B><I>filename</I>
<DD>
Send output to <I>filename</I>.
</DL>
<P>
<P>
<A NAME="lbAG">&nbsp;</A>
<H2>FILE OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="18"><B>-q</B>
<DD>
Print non-printable characters in filenames as question marks instead of the
default.
</DL>
<P>
<DL COMPACT>
<DT id="19"><B>-N</B>
<DD>
Print non-printable characters as is instead of as escaped octal numbers.
</DL>
<P>
<DL COMPACT>
<DT id="20"><B>-Q</B>
<DD>
Quote the names of files in double quotes.
</DL>
<P>
<DL COMPACT>
<DT id="21"><B>-p</B>
<DD>
Print the file type and permissions for each file (as per ls -l).
</DL>
<P>
<DL COMPACT>
<DT id="22"><B>-u</B>
<DD>
Print the username, or UID # if no username is available, of the file.
</DL>
<P>
<DL COMPACT>
<DT id="23"><B>-g</B>
<DD>
Print the group name, or GID # if no group name is available, of the file.
</DL>
<P>
<DL COMPACT>
<DT id="24"><B>-s</B>
<DD>
Print the size of each file in bytes along with the name.
</DL>
<P>
<DL COMPACT>
<DT id="25"><B>-h</B>
<DD>
Print the size of each file but in a more human readable way, e.g. appending a
size letter for kilobytes (K), megabytes (M), gigabytes (G), terabytes (T),
petabytes (P) and exabytes (E).
</DL>
<P>
<DL COMPACT>
<DT id="26"><B>--si</B>
<DD>
Like <B>-h</B> but use SI units (powers of 1000) instead.
</DL>
<P>
<DL COMPACT>
<DT id="27"><B>--du</B>
<DD>
For each directory report its size as the accumulation of sizes of all its files
and sub-directories (and their files, and so on). The total amount of used
space is also given in the final report (like the 'du -c' command.) This option
requires tree to read the entire directory tree before emitting it, see
<B>BUGS AND NOTES</B> below. Implies <B>-s</B>.
</DL>
<P>
<DL COMPACT>
<DT id="28"><B>-D</B>
<DD>
Print the date of the last modification time or if <B>-c</B> is used, the last
status change time for the file listed.
</DL>
<P>
<DL COMPACT>
<DT id="29"><B>-F</B>
<DD>
Append a `/' for directories, a `=' for socket files, a `*' for executable
files, a `&gt;' for doors (Solaris) and a `|' for FIFO's, as per ls -F
</DL>
<P>
<DL COMPACT>
<DT id="30"><B>--inodes</B>
<DD>
Prints the inode number of the file or directory
</DL>
<P>
<DL COMPACT>
<DT id="31"><B>--device</B>
<DD>
Prints the device number to which the file or directory belongs
</DL>
<P>
<P>
<A NAME="lbAH">&nbsp;</A>
<H2>SORTING OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="32"><B>-v</B>
<DD>
Sort the output by version.
</DL>
<P>
<DL COMPACT>
<DT id="33"><B>-t</B>
<DD>
Sort the output by last modification time instead of alphabetically.
</DL>
<P>
<DL COMPACT>
<DT id="34"><B>-c</B>
<DD>
Sort the output by last status change instead of alphabetically. Modifies the
<B>-D</B> option (if used) to print the last status change instead of
modification time.
</DL>
<P>
<DL COMPACT>
<DT id="35"><B>-U</B>
<DD>
Do not sort. Lists files in directory order. Disables <B>--dirsfirst</B>.
</DL>
<P>
<DL COMPACT>
<DT id="36"><B>-r</B>
<DD>
Sort the output in reverse order. This is a meta-sort that alter the above sorts.
This option is disabled when <B>-U</B> is used.
</DL>
<P>
<DL COMPACT>
<DT id="37"><B>--dirsfirst</B>
<DD>
List directories before files. This is a meta-sort that alters the above sorts.
This option is disabled when <B>-U</B> is used.
</DL>
<P>
<DL COMPACT>
<DT id="38"><B>--sort</B>[<B>=</B>]<I>type</I>
<DD>
Sort the output by <I>type</I> instead of name. Possible values are:
<B>ctime</B> (<B>-c</B>),
<B>mtime</B> (<B>-t), size</B>, or <B>version</B> (<B>-v).
<P>
</DL>
</B><A NAME="lbAI">&nbsp;</A>
<H2>GRAPHICS OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="39"><B>-i</B>
<DD>
Makes tree not print the indentation lines, useful when used in conjunction
with the <B>-f</B> option. Also removes as much whitespace as possible when used
with the <B>-J</B> or <B>-x</B> options.
</DL>
<P>
<DL COMPACT>
<DT id="40"><B>-A</B>
<DD>
Turn on ANSI line graphics hack when printing the indentation lines.
</DL>
<P>
<DL COMPACT>
<DT id="41"><B>-S</B>
<DD>
Turn on CP437 line graphics (useful when using Linux console mode fonts). This
option is now equivalent to `--charset=IBM437' and may eventually be depreciated.
</DL>
<P>
<DL COMPACT>
<DT id="42"><B>-n</B>
<DD>
Turn colorization off always, over-ridden by the <B>-C</B> option.
</DL>
<P>
<DL COMPACT>
<DT id="43"><B>-C</B>
<DD>
Turn colorization on always, using built-in color defaults if the LS_COLORS or
TREE_COLORS environment variables are not set. Useful to colorize output to a
pipe.
</DL>
<P>
<P>
<A NAME="lbAJ">&nbsp;</A>
<H2>XML/JSON/HTML OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="44"><B>-X</B>
<DD>
Turn on XML output. Outputs the directory tree as an XML formatted file.
</DL>
<P>
<DL COMPACT>
<DT id="45"><B>-J</B>
<DD>
Turn on JSON output. Outputs the directory tree as an JSON formatted array.
</DL>
<P>
<DL COMPACT>
<DT id="46"><B>-H </B><I>baseHREF</I>
<DD>
Turn on HTML output, including HTTP references. Useful for ftp sites.
<I>baseHREF</I> gives the base ftp location when using HTML output. That is, the
local directory may be `/local/ftp/pub', but it must be referenced as
`<A HREF="ftp://hostname.organization.domain/pub'">ftp://hostname.organization.domain/pub'</A> (<I>baseHREF</I> should be
`<A HREF="ftp://hostname.organization.domain').">ftp://hostname.organization.domain').</A> Hint: don't use ANSI lines with this
option, and don't give more than one directory in the directory list. If you
wish to use colors via CSS style-sheet, use the -C option in addition to this
option to force color output.
</DL>
<P>
<DL COMPACT>
<DT id="47"><B>-T </B><I>title</I>
<DD>
Sets the title and H1 header string in HTML output mode.
</DL>
<P>
<DL COMPACT>
<DT id="48"><B>--nolinks</B>
<DD>
Turns off hyperlinks in HTML output.
</DL>
<P>
<P>
<A NAME="lbAK">&nbsp;</A>
<H2>INPUT OPTIONS</H2>
<P>
<B>--fromfile</B>
Reads a directory listing from a file rather than the file-system. Paths
provided on the command line are files to read from rather than directories to
search. The dot (.) directory indicates that tree should read paths from
standard input.
<P>
<A NAME="lbAL">&nbsp;</A>
<H2>MISC OPTIONS</H2>
<P>
<DL COMPACT>
<DT id="49"><B>--help</B>
<DD>
Outputs a verbose usage listing.
</DL>
<P>
<DL COMPACT>
<DT id="50"><B>--version</B>
<DD>
Outputs the version of tree.
</DL>
<P>
<DL COMPACT>
<DT id="51"><B>--</B>
<DD>
Option processing terminator. No further options will be processed after this.
</DL>
<P>
<P>
<BR>
<A NAME="lbAM">&nbsp;</A>
<H2>FILES</H2>
/etc/DIR_COLORS<TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>System color database.<BR>
<BR>
~/.dircolors<TT>&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Users color database.<BR>
<BR>
<P>
<A NAME="lbAN">&nbsp;</A>
<H2>ENVIRONMENT</H2>
<B>LS_COLORS</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Color information created by dircolors<BR>
<BR>
<B>TREE_COLORS</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;</TT>Uses this for color information over LS_COLORS if it is set.<BR>
<BR>
<B>TREE_CHARSET</B><TT>&nbsp;&nbsp;&nbsp;</TT>Character set for tree to use in HTML mode.<BR>
<BR>
<B>CLICOLOR</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Enables colorization even if TREE_COLORS or LS_COLORS is not set.<BR>
<BR>
<B>CLICOLOR_FORCE</B><TT>&nbsp;</TT>Always enables colorization (effectively -C)<BR>
<BR>
<B>LC_CTYPE</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Locale for filename output.<BR>
<BR>
<B>LC_TIME</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Locale for timefmt output, see <B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3).<BR>
<BR>
<B>TZ</B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>Timezone for timefmt output, see <B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3).<BR>
<P>
<A NAME="lbAO">&nbsp;</A>
<H2>AUTHOR</H2>
Steve Baker (<A HREF="mailto:ice@mama.indstate.edu">ice@mama.indstate.edu</A>)
<BR>
HTML output hacked by Francesc Rocher (<A HREF="mailto:rocher@econ.udg.es">rocher@econ.udg.es</A>)
<BR>
Charsets and OS/2 support by Kyosuke Tokoro (<A HREF="mailto:NBG01720@nifty.ne.jp">NBG01720@nifty.ne.jp</A>)
<P>
<A NAME="lbAP">&nbsp;</A>
<H2>BUGS AND NOTES</H2>
Tree does not prune &quot;empty&quot; directories when the -P and -I options are used by
default. Use the --prune option.
<P>
The -h and --si options round to the nearest whole number unlike the ls
implementations which rounds up always.
<P>
Pruning files and directories with the -I, -P and --filelimit options will
lead to incorrect file/directory count reports.
<P>
The --prune and --du options cause tree to accumulate the entire tree in memory
before emitting it. For large directory trees this can cause a significant delay
in output and the use of large amounts of memory.
<P>
The timefmt expansion buffer is limited to a ridiculously large 255 characters.
Output of time strings longer than this will be undefined, but are guaranteed
to not exceed 255 characters.
<P>
XML/JSON trees are not colored, which is a bit of a shame.
<P>
Probably more.
<P>
<A NAME="lbAQ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+dircolors">dircolors</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+ls">ls</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+find">find</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+du">du</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3)
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="52"><A HREF="#lbAB">NAME</A><DD>
<DT id="53"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="54"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="55"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="56"><A HREF="#lbAF">LISTING OPTIONS</A><DD>
<DT id="57"><A HREF="#lbAG">FILE OPTIONS</A><DD>
<DT id="58"><A HREF="#lbAH">SORTING OPTIONS</A><DD>
<DT id="59"><A HREF="#lbAI">GRAPHICS OPTIONS</A><DD>
<DT id="60"><A HREF="#lbAJ">XML/JSON/HTML OPTIONS</A><DD>
<DT id="61"><A HREF="#lbAK">INPUT OPTIONS</A><DD>
<DT id="62"><A HREF="#lbAL">MISC OPTIONS</A><DD>
<DT id="63"><A HREF="#lbAM">FILES</A><DD>
<DT id="64"><A HREF="#lbAN">ENVIRONMENT</A><DD>
<DT id="65"><A HREF="#lbAO">AUTHOR</A><DD>
<DT id="66"><A HREF="#lbAP">BUGS AND NOTES</A><DD>
<DT id="67"><A HREF="#lbAQ">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:28 GMT, March 31, 2021
</BODY>
</HTML>