Reference articles on history, science, culture and more
Encyclopedia

Tree (command)

Shell command in various operating systems

Image credit is listed at the end of this article.

In computing, tree is a recursive directory listing command or program that produces a depth-indented listing of files. Originating in PC- and MS-DOS, it is found in Digital Research FlexOS, IBM/Toshiba 4690 OS, PTS-DOS, FreeDOS, IBM OS/2, Microsoft Windows, and ReactOS. A version for Unix and Unix-like systems is also available.

The tree command is frequently used as part of a technical support scam, where the command is used to occupy the command prompt screen, while the scammer, pretending to be technical support, types additional text that is supposed to look like output of the command.

01Overview

With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files or directories found in the given directories each in turn. Upon completion of listing all files and directories found, tree returns the total number of files and directories listed. There are options to change the characters used in the output, and to use color output.

The command is available in MS-DOS versions 3.2 and later and IBM PC DOS releases 2 and later. Digital Research DR DOS 6.0, Itautec SISNE plus, and Datalight ROM-DOS include an implementation of the tree command.

The Tree Command for Linux was developed by Steve Baker. The FreeDOS version was developed by Dave Dunfield and the ReactOS version was developed by Asif Bahrainwala. All three implementations are licensed under the GNU General Public License.

The Tree command is also available in macOS as a formula installed via the command line Homebrew package manager.

02Example

$ tree path/to/folder/ path/to/folder/ ├── a-first.html ├── b-second.html ├── subfolder │ ├── readme.html │ ├── code.cpp │ └── code.h └── z-last-file.html 1 directories, 6 files
Watch videos about Tree (command)Explainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article Tree (command), written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Images, from Wikimedia Commons:

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.