Original URL: http://jingyan.baidu.com/article/acf728fd19c7eff8e510a3eb.html
Today's gadget to share the use of a very useful command for Linux systems: The tree command can display a file directory structure in the form of trees, which is ideal for us to introduce to others the constituent framework of our file directory, and the command can be output to a text file using the appropriate parameters.
This experience shows:
This proposal for small series is only suitable for 10.10 versions of the Ubuntu system, followed by 11.04, 11.10 ... 14.04 system because the default desktop is different, so this experience is not applicable, to use, then please install the GNOME desktop
Method/Step
In the Ubuntu system, the default is no tree this command, need to install, with the following command to install the tree This command tool sudo apt-get install tree
First of all, to say how to use the tree This command, in fact, there is a very simple way, is to directly see the help of the tree, enter the following command, you can see the help information about the tree command tree--help
Now let's talk about how to use tree, the simplest way is to directly input the tree command, will automatically give us a tree to list the current directory of files and folders, without any parameters, it will automatically list the current directory of all the depth level of files and directories
Let's talk about how to look at different levels of subdirectories and files using the "Tree-l 1" command, view only the current first-level directories and files using the "Tree-l 2" command, view only the current second-level directories and files using the "tree-l N" command, View only directories and files at the current nth level
The above is only to show the current results, but in many cases we want to save this directory structure information, our own or send to others, we will tell you how to achieve this goal
Use the following command to save the directory structure information input for the second-level subdirectory of the current file to the/home/xyh/tree.txt file
Command:
Tree-l 2 >/home/xyh/tree.txt
Below we open the/home/xyh/tree.txt file to see if the result is the same as the result of the command we used earlier, we can see that the result of saving the file is to use the "Tree-l 2" command to enter the result
The "Go" Linux tree command displays the file directory structure in a hierarchical structure----good