Whenever I do the source code review of any project, I create a checklist where I also create a sheet that contains the directories, files, etc in the proper tree structure. We can use -C flag with tree command to produce the colorized output $ tree -C directory/ We can use -d flag with the tree command to list only directories of specific directories. Hidden files and directories $ tree -a directory/ The tree command does not list the hidden files, we have to use -a flag with tree command to list all the files and directories(i.e. We can tweak this command in many ways like listing only directories, filtering with regexes, listing with the colorized format, hidden files should be shown or not, etc. We can simply use tree command with the directory name specification like following, $ tree directory/Īs the tree command will produce depth indented recursive listing of files, It’s very helpful to analyze the directory structures of any directories. help Print usage and this help message and exit. fromfile Reads paths from files (.=stdin) nolinks Turn off hyperlinks in HTML output. T string Replace the default HTML title and H1 header with string. H baseHREF Prints out HTML format with baseHREF as top directory. J Prints out an JSON representation of the tree. X Prints out an XML representation of the tree. n Turn colorization off always (-C overrides). S Print with CP437 (console) graphics indentation lines. A Print ANSI lines graphic indentation lines. sort X Select sort: name,version,size,mtime,ctime. dirsfirst List directories before files (-U disables). c Sort files by last status change time. v Sort files alphanumerically by version. device Print device ID number to which each file belongs. D Print the date of last modification or (-c) status change.
si Like -h, but use in SI units (powers of 1000). h Print the size in a more human readable way. g Displays file group owner or GID number. q Print non-printable characters as '?'.
o filename Output to file instead of stdout. timefmt Print and format time according to the format. filelimit # Do not descend dirs with more than # files in them. charset X Use charset X for terminal/HTML and indentation line output. noreport Turn off file/directory count at end of tree listing. matchdirs Include directory names in -P pattern matching. ignore-case Ignore case when pattern matching. I pattern Do not list files that match the given pattern. P pattern List only those files that match the pattern given. R Rerun tree when max dir level reached. L level Descend only level directories deep.
f Print the full path prefix for each file. l Follow symbolic links like directories. Here is detailed information about all the flags of the tree command utility.
$ apt-get install treeĪfter the installation, use the tree command as follows tree command basic information In Linux, we can use the apt package manager to install the tree command utility.