Home >Computer Tutorials >Computer Knowledge >Use tree to generate a file directory tree for display

Use tree to generate a file directory tree for display

PHPz
PHPzforward
2024-03-01 17:46:021392browse

tree is a command line tool that recursively lists the contents of a directory in a tree format, so that all directories, subdirectories and files are listed in a hierarchical manner, thus intuitively Shows the organization of files and folders.

The following is the installation and use method of tree under Windows and Linux systems

Installation and use of tree under Linux

  • Installing tree under Linux:
  • apt update && apt install tree
  • The following are common ways of using the tree command.
  • # 显示指定路径下的目录树
    tree /d/temp
    # 限制最大的展示深度
    tree -L 3
    # 只显示目录不显示文件
    tree -d
    # 显示包括隐藏的文件和目录
    tree -a
    # 为每个文件打印完整路径前缀
    tree -f
  • In addition, the directory tree can also be output to the specified file.
  • tree /f > tree.txt

    Installation and use of tree under Windows

  • Download binaries in Tree for Windows.
  • Use tree to generate a file directory tree for display

  • Extract the downloaded file and find the tree.exe file in the bin folder. Move the file to your preferred software installation directory, such as C:ProgramFilestreetree.exe.
  • Open system properties and add the tree directory to the environment variable in the following order.
  • Use tree to generate a file directory tree for display

  • Find the folder where you need to create a new tree directory, open Git Bash in Terminal and enter the command. (For specific configuration, see Windows Terminal Usage and Configuration)
  • The usage of tree under Windows is consistent with Linux, so there is no need to go into details.
  • The above is the detailed content of Use tree to generate a file directory tree for display. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete