$TREE The $ tree command is a shell (Unix/Linux/macOS) command used to display the directory structure of a path or the current working directory as a tree. It gives a visual representation of folders and subfolders in a nested format.

โธป

๐Ÿ“Œ Basic Usage

$ tree

This will recursively list directories and files in the current directory in a tree-like format.

โธป

๐Ÿ”ง Example Output

$ tree
.
โ”œโ”€โ”€ file1.txt
โ”œโ”€โ”€ dir1
โ”‚ โ”œโ”€โ”€ file2.txt
โ”‚ โ””โ”€โ”€ subdir1
โ”‚ โ””โ”€โ”€ file3.txt
โ””โ”€โ”€ dir2
โ””โ”€โ”€ file4.txt

โธป

โœ… Useful Options

Option Description
-L <n> Limit display to <n> levels of directories.
-d List directories only.
-a Show hidden files (those starting with .).
-f Print full path for each file.
--dirsfirst List directories before files.
-h Print sizes in human-readable format.

โธป

๐Ÿ“ฆ Install tree (if not already installed)
โ€ข Ubuntu/Debian:

sudo apt install tree

โ€ข Fedora:

sudo dnf install tree

โ€ข macOS (with Homebrew):

brew install tree

โธป

Let me know if you want help visualizing a specific directory or want to combine it with other shell commands!