tree is a recursive directory displaying command that helps to see the in depth indented listing of directories and files.
How to install tree command on macOS Terminal?
You can make use of Home-brew to install the tree package,
- Open Terminal,
- Type command: brew install tree
code2care@mac Desktop % brew install tree
==> Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.arm64_big_sur.bottle.tar.gz
Already downloaded: /Users/code2care/Library/Caches/Homebrew/downloads/ e446cb0fe0006900ce03f20b28170d16fc298e8ffad73a071f4d603df97ecb58 --tree-1.8.0.arm64_big_sur.bottle.tar.gz
==> Pouring tree-1.8.0.arm64_big_sur.bottle.tar.gz
🍺 /opt/homebrew/Cellar/tree/1.8.0: 8 files, 158.5KB
How to use tree command?
Just be in the dir where you want to see the structure of files and folders and type tree,
% tree
.
├── Java
├── My\ Books
├── Python\ Files
└── Samples
└── Sub-folder
4 directories, 1 file
As you can see when I ran the tree command on the Desktop - it displayed all the folders and files it contains, with a summary of how many files are folders are present in Desktop. The dot represents the root. and you can see the files or folders within a file with an indent.
If you want to restrict the number of levels you want to see you can use -L option followed the level number to reduce the depth.
Example:code2care@mac Desktop % tree -L 1
.
├── Java
├── My\ Books
├── Python\ Files
└── Samples
4 directories, 0 files

- How to find path of file on Mac Terminal
- How to disable Siri on Mac Monterey
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Select Line Number TextEdit on Mac
- Go to Specific file path using Mac Finder
- How to find Java HOME in Mac Terminal
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Must Know Homebrew Commands for Mac/Linux Users
- How to Insert an Inverted Question Mark on Mac ¿
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- How to make macOS Terminal window Transparent (or Opaque)
- How to check of Updates on Microsoft Edge Browser on Mac (macOS)
- Limit scrollback rows in macOS Terminal
- How to identify installed Java (JDK) Version on macOS
- Keyboard Shortcut to delete a file on a Mac [Macbook]
- Open Docker from Terminal Command on Mac
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023]
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- How to remove username from Mac Menu Bar?
- macOS Ventura XCode Command Line Tools Installation
- Where is .zshrc file located in macOS
- How to Show Path of Files or App in Mac Spotlight Search
- How to enable root user on Mac Terminal
- Install Java 17 (LTS) JDK on ARM based M1/M2 Mac Natively
- Error code 0xCAA82EE2: Something went wrong (request timed out) [Microsoft] - Microsoft
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj] - Java
- Customize Praise badge for Microsoft Teams with own images, values, brand - Microsoft
- INSTALL_FAILED_INSUFFICIENT_STORAGE Error Android Emulator - Android
- remove div vertical scroll - Html
- Select Line Number TextEdit on Mac - MacOS
- [fix] fatal: pathspec index.html did not match any files error - Git
- How to extract Java Jar/War/Ear files in Linux - Java