It won’t be incorrect to say the ls command is the defacto conventional when it comes to record listing material on the Linux system management range. However, there are available some solutions that have their own powerful factors in comparison to ls. Once such device is tree, fundamentals of which we’ll be talking about here in this guide.
But before we do that, it’s value referring to that all illustrations here have been examined on an Ie8 18.04 LTS device.
Linux shrub command
As the name indicates, the shrub management in Linux system details material of internet directories in a tree-like framework. Following is its syntax:
tree [OPTIONS] [directory]
And here’s how the tool’s man web page describes it:
Tree is a recursive record listing system which makes a detail indented record of information,
which is colorized ala dircolors if the LS_COLORS atmosphere varying is set and outcome is to tty.
With no justifications, shrub details the information in the present record. When record justifications are
given, shrub details all the information and/or internet directories seen in the given internet directories each in convert.
Upon finishing record all files/directories discovered, shrub profits the count of information
and/or internet directories detailed.
In situation the shrub management isn’t set up in your Ie8 box, you can snap it up using the following command:
sudo apt-get set up tree
Following are some Q&A designed illustrations that should provide you with a excellent example of how the shrub management performs.
Q1. How does shrub management work?
Basic utilization is simple enough. Just perform the ‘tree’ management without any choice. Here’s an example:
Here’s the outcome this management created on my system:
So you can see a tree-like framework was created in the outcome. Remember that it’s the present operating record whose material are shown automatically. If you want to show material of any other record, then you’ll have to specify the way to that record in feedback.
Q2. How to develop shrub show invisible information as well?
By conventional, the shrub management does not show invisible information. However, if you want, you can also make shrub do that by using the -a management range choice.
Here’s what the man web page says about -a:
All information are printed. By conventional shrub does not make invisible information (those starting with a dot `.')
. In no occasion does shrub make the computer file system constructs `.' (current directory) and `..'
Q3. How to develop shrub only show internet directories in output?
Suppose you only want the shrub management to show record records in outcome. You can do that using the -d management range choice.
For example, the following command:
produced this output:
Q4. How to develop shrub make finish direction prefix for files?
This can be done using the -f management range choice. Here’s an example:
Here’s aspect of the outcome generated by this management on my system:
Q5. How to manage the detail of record shrub in output?
The shrub management also allows you to management the detail of record shrub created in outcome. This you can do using the -L management range choice which needs a variety value that represents the allowed record detail. For example:
tree -d -L 1
The above management would make sure that only first degree of internet directories get shown in outcome.
Q6. How to precisely keep certain titles in output?
The shrub management provides a -I management range choice that needs you to move a design as feedback. Based upon on what they are of files/directories you want not to be shown in outcome, build a design. For example, I needed to show only internet directories, but did not want any name with ‘Ubuntu’ design (case sensitive), so I used the -I management range choice in the following way:
tree -d -I *Ubuntu
While we’ve mentioned quite a few shrub management range choices, the truth is it provides a lot more functions. Once you’re done exercising what all we’ve mentioned here, go to the shrub management man web page to understand more about it.