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 Install tree command in Mac](https://code2care.org/howto/display-directory-tree-mac-terminal/images/Install tree command in Mac.png)
Install tree command in Mac
More Posts related to MacOS,
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
More Posts:
- Write JSON to file in pretty-printed Format using Java Jackson - Java
- Auto Execute a command or script on Mac Terminal Startup - MacOS
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass - Java
- Android read text file from internal storage - Android
- How to convert a Postman request to cURL Command - cURL
- Convert text to random case using Notepad++ - NotepadPlusPlus
- Change SharePoint search results FullTextSqlQuery RowLimit 10000 - SharePoint
- Fix - cd: no such file or directory: .zshrc - zsh