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

Install tree command in Mac
More Posts related to MacOS,
- How to Display Analog Clock on Mac Menu Bar
- Shutdown Mac Terminal Command
- How to know the Serial Number of MacBook on macOS Ventura 13.0
- macOS: Remove Desktop or Documents Folder from iCloud Drive Syncing
- [fix] How to Show file extensions on all files on Mac
- How to install Zoom Add-in to Outlook (Mac)
- How to turn off Stage Manager - macOS Ventura
- Fix - Xode - Internal logic error: Connection was invalidated
- How to do calculations in Mac Terminal
- How to delete a Page in Microsoft Word File on Mac (macOS)
- How to Refresh Mac Desktop
- How to install Java on macOS [Big Sur]
- How to Disable Mac Terminal Bell Sound
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to Uninstall Brew on Mac
- Find your macOS version
- Change TextEdit File Encoding
- AppleScript Example with TextEdit
- How to install homebrew (brew) on M1 Mac
- How to Find File and Directory Size in Mac Terminal
- How to open new tab in Sublime Text Editor [macOS]
- How to list all users in Mac Terminal
- Turn off Auto-Capitalization on macOS Ventura 13
- How to check Command Line Tools Version [Updated for Ventura]
- Change Current User Password using Mac Terminal Command
More Posts:
- Python: Pandas Rename Columns with List Example - Python
- Use Google Chrome Canvas to create drawings - Chrome
- Jupyter Notebook: 404 : Not Found - You are requesting a page that does not exist! - Python
- Fix Error Code: 80090030 in Microsoft Outlook/Teams - Microsoft
- How to download and install Slack on Mac - MacOS
- How to Upload Video to YouTube from Android - Android
- Fix: Failed in attempting to update the source: winget - Windows
- Python: Fix command not found pip or pip3 on zsh shell - Python