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 Open Finder using Mac Terminal
- How to install maven in macOS using Terminal Command
- How to install iTerm2 Mac Terminal Alternative
- Find Mac version using terminal command
- Zsh Shell: Custom alias that you may find useful
- How to Uninstall Brew on Mac
- Go to Specific file path using Mac Finder
- How to open new tabs macOS Terminal
- fix macOS: The digital signature on the update is missing or invalid. Ventura
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- Closest Alternate to Notepad on Mac
- How to Open Trash on Mac
- How to uninstall Microsoft Outlook on Mac
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- [Vi/Vim] How to move cursor to the start of a line
- macOS 13 Ventura - The New About this Mac Window
- Best Free Gif screen capture app now available for M1 Chip Mac - LICECap
- 30+ Zoom video communications application shortcuts for macOS
- How to create alias in macOS
- How to install Node using Brew on Mac
- How to start/boot macOS in safe mode - Big Sur 11.0, Catalina 10.15, or Mojave 10.14
- Cant find System Preferences... under macOS Ventura Apple Menu?
- Mac turn dark mode on or off using terminal command
- How to Close Safari in Mac using Keyboard shortcut
- How to Upgrade Mac from Monterey to macOS Ventura
- Ubuntu zsh: command not found: nano - zsh
- Create Duplicate Line Visual Studio Code (above or below) Example - HowTos
- [Solved] SharePoint Search Internal server error exception - SharePoint
- Android : Class file collision: A resource exists with a different case - Android
- Get the Size of HTTP Response using cURL Command (Content Length) - cURL
- Android Activity Main xml stuck loading - Android-Studio
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac - Docker
- Go to Line Number option in Windows Notepad - NotepadPlusPlus