linux view file tree structure

Posted by bedted on Tue, 31 Dec 2019 06:39:21 +0100

tree installation:

Using the tree command under linux can easily view the file tree structure under the specified directory, but some systems do not install the command, so you need to install it manually. Take the installation of Ubuntu as an example, and other linux systems are similar.

To install under ubuntu:
With the network connected, install the tree by entering the following command on the command line:

sudo apt-get install tree

Usage and parameters:

tree -d -L 1
Note:
Tree: Show tree
-d: Show directories only
-50: Select directory depth to display
1: Show only one level of depth, that is, do not recurse subdirectories

Example 1 [tree]:

sky@sky-virtual-machine:~/work/linuxdemo/CMake/demo1$ tree 
.
├── CMakeCache.txt
├── CMakeFiles
│   ├── 2.8.12.2
│   │   ├── CMakeCCompiler.cmake
│   │   ├── CMakeCXXCompiler.cmake
│   │   ├── CMakeDetermineCompilerABI_C.bin
│   │   ├── CMakeDetermineCompilerABI_CXX.bin
│   │   ├── CMakeSystem.cmake
│   │   ├── CompilerIdC
│   │   │   ├── a.out
│   │   │   └── CMakeCCompilerId.c
│   │   └── CompilerIdCXX
│   │       ├── a.out
│   │       └── CMakeCXXCompilerId.cpp
│   ├── cmake.check_cache
│   ├── CMakeDirectoryInformation.cmake
│   ├── CMakeOutput.log
│   ├── CMakeTmp
│   ├── Demo.dir
│   │   ├── build.make
│   │   ├── C.includecache
│   │   ├── cmake_clean.cmake
│   │   ├── DependInfo.cmake
│   │   ├── depend.internal
│   │   ├── depend.make
│   │   ├── flags.make
│   │   ├── link.txt
│   │   ├── main.c.o
│   │   └── progress.make
│   ├── Makefile2
│   ├── Makefile.cmake
│   ├── progress.marks
│   └── TargetDirectories.txt
├── cmake_install.cmake
├── CMakeLists.txt
├── Demo
├── main.c
└── Makefile

6 directories, 32 files

Example 2 [tree -d]:

sky@sky-virtual-machine:~/work/linuxdemo/CMake/demo1$ tree -d
.
└── CMakeFiles
    ├── 2.8.12.2
    │   ├── CompilerIdC
    │   └── CompilerIdCXX
    ├── CMakeTmp
    └── Demo.dir

6 directories

Example 3 [tree -L 1]:

sky@sky-virtual-machine:~/work/linuxdemo/CMake/demo1$ tree -L 1
.
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── CMakeLists.txt
├── Demo
├── main.c
└── Makefile

1 directory, 6 files

Topics: cmake Makefile Linux Ubuntu