🌳tree command

What is the tree command?

The tree command is a utility tool in Linux that displays the directory structure in a tree-like format. It displays all the subdirectories and files in a hierarchical manner, making it easier to understand the orga…


This content originally appeared on DEV Community and was authored by AYON KARMAKAR

What is the tree command?

The tree command is a utility tool in Linux that displays the directory structure in a tree-like format. It displays all the subdirectories and files in a hierarchical manner, making it easier to understand the organization of your files and directories.

Installing the tree command

sudo apt-get install tree

How to use the tree command?

tree [options] [directory]

Here, [options] refers to the various options you can use with the command. [directory] refers to the path of the directory whose structure you want to display.

For example, to display the directory structure of the current directory, you can simply type:

tree

Some useful options

Here are some useful options you can use with the tree command:

  • -a: This option will display hidden files and directories as well.
  • -L level: This option allows you to specify the depth to which the directory structure should be displayed. For example, tree -L 2 will display the structure of the current directory and its immediate subdirectories only.
  • -d: This option will display only directories and not files.
  • -I pattern: This option allows you to specify a pattern to exclude files and directories from the tree structure. For example, tree -I '*.txt' will exclude all files with the extension .txt.

Examples:

Example 1: Displaying the directory structure of a specific directory

tree /home/user/Documents

This will display the directory structure of the Documents directory in a

Example 2: Displaying the directory structure of a specific Level 2

tree -L 2

Image description


This content originally appeared on DEV Community and was authored by AYON KARMAKAR


Print Share Comment Cite Upload Translate Updates
APA

AYON KARMAKAR | Sciencx (2023-03-17T17:51:40+00:00) 🌳tree command. Retrieved from https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/

MLA
" » 🌳tree command." AYON KARMAKAR | Sciencx - Friday March 17, 2023, https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/
HARVARD
AYON KARMAKAR | Sciencx Friday March 17, 2023 » 🌳tree command., viewed ,<https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/>
VANCOUVER
AYON KARMAKAR | Sciencx - » 🌳tree command. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/
CHICAGO
" » 🌳tree command." AYON KARMAKAR | Sciencx - Accessed . https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/
IEEE
" » 🌳tree command." AYON KARMAKAR | Sciencx [Online]. Available: https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/. [Accessed: ]
rf:citation
» 🌳tree command | AYON KARMAKAR | Sciencx | https://www.scien.cx/2023/03/17/%f0%9f%8c%b3tree-command/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.