DEV Community

box
box

Posted on

1

Display Dir Structure in Tree Format.

Environment

  • Mac

    • CPU: Apple M4
    • OS: Sequoia 15.1.1
  • Zsh

    • Version: 5.9
  • Homebrew

    • Version: 4.4.10

Sample

Run the following command to create the sample directories and files.

mkdir -p ./dir1/dir2
touch ./file0.txt ./dir1/file1.txt ./dir1/dir2/file2.txt
Enter fullscreen mode Exit fullscreen mode

Flow

  1. Install tree command.

    brew install tree
    

    We can check the version of this command by running the following command.

    tree --version
    

    As of the time of writing, the version is 2.2.1.

  2. Run the command.

    tree
    

    The result is as follow.

    .
    ├── dir1
    │   ├── dir2
    │   │   └── file2.txt
    │   └── file1.txt
    └── file0.txt
    

Manual

Running the following command will display the manual page for the tree command in Zsh.

man tree
Enter fullscreen mode Exit fullscreen mode

After reading, press the q key to return to Zsh.

The source for tree v2.2.1 manual is here.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay