Under the Linux system, use the tree command to implement the tree structure display directory

  
. Today, Xiaobian is used to share the very useful commands of the Linux system: the tree command can display the file directory structure in a tree structure, which is very suitable for us to introduce to others. The composition of our file directory, and the command can also output the command results to a text file with the appropriate parameters. This proposal for Xiaobian is only suitable for ubuntu systems prior to 10.10, followed by 11.04, 11.10. . . 14.04 system is different because the default desktop is used, so this experience is not applicable. If you want to use it, please install GNOME desktop 1. In ubuntu system, there is no tree command by default. You need to install it. You can install tree with the following command. Command tool sudo apt-get install tree2, first Xiaobian said how to use the tree command, in fact, there is a very simple way, is to directly view the help on the tree, enter the following command, you can view the help of the tree command Information tree --help3, let's talk about how to use the tree, the easiest way to use is to directly enter the tree command, it will automatically give us a list of files and folders in the current directory, without any Parameters, it will automatically list all the depth level files and directories under the current directory. 4, let's talk about how to view different levels of subdirectories and files using the "tree -L 1 " this command, only view the current first level Use the "tree -L 2 " command to view only the current second-level directories and files. Use the "tree -LN " command to view only the current N-level directory and file. 5. The above is just to display the current result, but in many cases we want to save this directory structure information. Alternately or sent to others, let's talk about how to achieve this. Use the following command to save the directory structure information of the second-level subdirectory of the current file to the /home/xyh/tree.txt file: tree - L 2 > /home/xyh/tree.txt6, below we open the /home/xyh/tree.txt file to see if the saved result is the same as the result displayed by the command we used before, you can see the file saved. The result is the input result of the command using "tree -L 2 " 
Copyright © Windows knowledge All Rights Reserved