Linux tree command: display directory structure

table of Contents

description

grammar

Usage example

Show directory structure

Keep only the directory name

Precautions

The specified directory name does not exist

Specify non-directory type


 

description

The tree command lists the file structure of a directory in the form of a tree diagram.

 

grammar

tree [-d] <dir>
parameter name description
-d Only the directory name is kept in the displayed structure

 

Usage example

Show directory structure

Use tree <directory name> to get the file structure of a directory.

$ tree FlaskDemo
FlaskDemo
├── render_demo.py
└── templates
    ├── for.html
    └── hello_world.html

1 directory, 3 files

Keep only the directory name

When the -d parameter is used, the display result of the tree command only retains the directory name.

$ tree FlaskDemo/ -d
FlaskDemo/
└── templates

1 directory

 

Precautions

The specified directory name does not exist

When the directory name specified to display the structure does not exist, the tree command displays "error opening dir"

$ tree fun
fun [error opening dir]

0 directories, 0 files

 

Specify non-directory type

The tree command can only display the file structure of a directory. When the specified name is not a directory type, the tree displays "error opening dir"

$ tree auto.sh
auto.sh [error opening dir]

0 directories, 0 files

 

Guess you like

Origin blog.csdn.net/TCatTime/article/details/113058732