Up to date: 03/06/2020 by Laptop Hope

tree lists the contents of directories in a tree-like format. It may be used to the construction of your file system.


tree is a recursive listing itemizing program that produces a depth-indented itemizing of information (which is colorized if the LS_COLORS environment variable is about) and output is to tty. With no arguments, tree lists the information within the present listing. When listing arguments are given, tree lists all of the information and/or directories discovered within the given directories every in flip. tree then returns the overall variety of information and/or directories listed.

By default, when a symbolic link is encountered, the trail that the symbolic hyperlink refers to is printed after the title of the hyperlink within the format:

title -> real-path

If the `-l‘ choice is given and the symbolic hyperlink refers to an precise listing, then tree will observe the trail of the symbolic hyperlink as if it have been an actual listing.


tree [-adfgilnopqrstuxACDFNS] [-L level [-R]] [-H baseHREF] [-T title] [-o file name] [–nolinks] [-P pattern] [-I pattern] [–inodes] [–device] [–noreport] [–dirsfirst] [–version] [–help] [–filelimit #] [–si] [–prune] [–du] [–timefmt format] [directory …]


–help Outputs a verbose utilization itemizing.
–version Outputs the version of tree.
-a All information are printed. By default, tree doesn’t print hidden information (these starting with a dot `.‘). In no occasion does tree print the file system constructs `.‘ (present listing) and `..‘ (earlier listing).
-d Listing directories solely.
-f Prints the complete path prefix for every file.
-i Tree won’t print the indentation traces. Helpful when used along with the -f choice.
-l Follows symbolic hyperlinks to directories as in the event that they have been directories. Hyperlinks that will lead to a recursive loop are averted.
-x Keep on the present file system solely, as with discover -xdev.
-P sample Listing solely these information that match the wildcard sample. Observe: it’s essential to use the -a choice to additionally think about these information starting with a dot `.‘ for matching. Legitimate wildcard operators are `*‘ (any zero or extra characters), `?‘ (any single character), `[…]‘ (any single character listed between brackets (non-obligatory (sprint) for character vary could also be used: ex: [A-Z]), and `[^…]‘ (any single character not listed in brackets) and `|‘ separates alternate patterns.
-I sample Don’t record these information that match the wildcard sample.
–prune Makes tree prune empty directories from the output, helpful when used along with -P or -I.
–filelimit # Don’t descend directories that include greater than # entries.
–timefmt format Prints (implies -D) and codecs the date in line with the format string which makes use of the strftime syntax.
–noreport Omits printing of the file and listing report on the finish of the tree itemizing.
-p Print the protections for every file (as per ls -l).
-s Print the scale of every file together with the title.
-u Print the username, or UID # if no username is obtainable, of the file.
-g Print the group title, or GID # if no group title is obtainable, of the file.
-D Print the date of the final modification time for the file listed.
–inodes Prints the inode variety of the file or listing
–device Prints the system quantity to which the file or listing belongs
-F Append a `/‘ for directories, a `=‘ for socket information, a `*‘ for executable information and a `|‘ for FIFO’s, as per ls -F
-q Print non-printable characters in file names as query marks as an alternative of the default carrot notation.
-N Print non-printable characters as is as an alternative of the default carrot notation.
-r Kind the output in reverse alphabetic order.
-t Kind the output by final modification time as an alternative of alphabetically.
–dirsfirst Listing directories earlier than information.
-n Flip colorization off all the time, overridden by the -C choice.
-C Flip colorization on all the time, utilizing built-in shade defaults if the LS_COLORS atmosphere variable isn’t set. Helpful to colorize output to a pipe.
-A Activate ANSI line graphics hack when printing the indentation traces.
-S Activate ASCII line graphics (helpful when utilizing linux console mode fonts). This feature is now equal to `–charset=IBM437‘ and can finally be depreciated.
-L degree Max show depth of the listing tree.
-R Recursively cross down the tree every degree directories (see -L choice), and at every of them execute tree once more including `-o 00Tree.html‘ as a brand new choice.
-H baseHREF Activate HTML output, together with HTTP references. Helpful for ftp websites. baseHREF provides the bottom ftp location when utilizing HTML output. That’s, the native listing could also be `/native/ftp/pub’, nevertheless it have to be referenced as `ftp://host-name.group.area/pub’ (baseHREF needs to be `ftp://hostname.group.area’). Trace: do not use ANSI traces with this selection, and do not give a couple of listing within the listing record. If you wish to use colours by way of CSS stylesheet, use the -C choice along with this selection to power shade output.
-T title Units the title and H1 header string in HTML output mode.
–charset charset Set the character set to make use of when outputting HTML and for line drawing.
–nolinks Turns off hyperlinks in HTML output.
-o file title Ship output to file title.



Shows the contents of the present listing and subdirectories in a tree. The output takes a graphical kind which can resemble the next instance:

. ├── config.dat ├── knowledge │ ├── data1.bin │ ├── data2.sql │ └── data3.inf ├── pictures │ ├── background.jpg │ ├── icon.gif │ └── emblem.jpg ├── program.exe └── readme.txt 2 directories, 9 information tree -I ‘instance*|bin|lib’

Shows a tree with out something starting with instance or containing ‘bin’ or ‘lib’ as specified within the sample.

tree -P ‘t*’

With a uppercase “P” you possibly can record information with a sample. This sample instance shows a tree solely containing directories starting with t or directories containing information that start with t.

tree -p

With a lowercase “p” you possibly can record a tree that additionally reveals the file permissions.

ls — Listing the contents of a listing or directories.


Leave a Reply