For code farmers, many project descriptions need to paste the directory structure (directory tree), manually write? Absolutely impossible

In fact, it is very simple, mainly using the tree command, Windows and Linux can be used

In Windows, run the tree command

It is also possible to use the tree command in CMD, the problem is that the parameters are not very many

By default, only the directory name is displayed

grammar
     
copy Copy successful!
  1. TREE [drive:] [path] [/F] [/A]

Arguments are case insensitive,/ a,/f are also acceptable

parameter describe
drive: Specifies the drive that contains the disk for which the directory structure is to be displayed
path Specifies the directory for which the directory structure is to be displayed
/F Displays the name of the file in each directory
/A Specifies that the tree will use text characters instead of graphic characters to display rows linking subdirectories
/? Displays help at a command prompt
     
copy Copy successful!
  1. D:\project\>tree /?
  2. Graphically displays the folder structure of a drive or pat
  3. TREE [drive:] [path] [/F] [/A]
  4. /F Display the names of the files in each folder.
  5. /A Use ASCII instead of extended characters.
  6. D:\project\>
Git used under

If you have Git installed on your Windows system, you can install the tree command under git_bash, and you can use many of the tree commands under git_bash

Install the tree in Git

To this address (gnuwin32.sourceforge.net/packages/tr… Binaries file

Then copy the tree.exe file in the bin directory to the usr/bin directory in the git installation directory, for example, C:\Program Files\ git \usr\bin

Git bash displays the secondary directory, ignoring node_modules and not displaying the file

     
     
  1. $ tree -L 2 -I "node_modules" -d
  2. .
  3. |-- app
  4. | |-- actions
  5. | |-- components
  6. | |-- constants
  7. | |-- containers
  8. | |-- dist
  9. | |-- reducers
  10. | |-- store
  11. | `-- utils
  12. |-- configs
  13. |-- dll
  14. |-- flow-typed
  15. | `-- npm
  16. |-- internals
  17. | |-- flow
  18. | |-- img
  19. | |-- mocks
  20. | `-- scripts
  21. |-- release
  22. |-- resources
  23. | `-- icons
  24. `-- test
  25. |-- actions
  26. |-- components
  27. |-- containers
  28. |-- e2e
  29. `-- reducers
  30. 27 directories

The tree command is used in Linux

Sudo yum -y install tree

Common commands

Display files and directories with maximum ‘num’ depth (where 1 indicates the current directory) :

     
  1. tree -L num

Display only directories:

     
  1. tree -d

Show hidden files at the same time:

     
  1. tree -a

Prints the tree without indentation, showing the full path (for -n without escaping Spaces and special characters) :

     
  1. tree -i -f

Print the size of each node next to it in human-readable format:

     
  1. tree -s -h

Filter trees using wildcard (GLOB) patterns:

     
copy Copy successful!
  1. tree -P *.txt

Ignore entries that match wildcard (glob) patterns:

     
  1. tree -I *.txt
grammar
     
  1. tree [-acdfghilnpqrstuvxACDFQNSUX] [-L level [-R]] [-H baseHREF] [-T title] [-o filename] [-nolinks] [-P pattern] [-I pattern] [-inodes] [-device] [-noreport] [-dirsfirst] [-version] [-help] [-filelimit #] [--si] [--prune] [--du] [--timefmt format] [--matchdirs] [--fromfile] [--] [directory ...]
describe

The tree is a recursive directory list of files generated by the program with depth indentation listed, which is colored ALA dircolors if the LS_COLORS environment variable is set and output is terminal. If there are no arguments, the tree lists the files in the current directory. When a directory argument is given, the tree lists in order all files and/or directories found in a given directory. After listing all the files/directories listed, the tree returns the total number of files and/or directories listed.

By default, when a symbolic link is encountered, the path referenced by the symbolic link is printed after the link name in the following format:

     
  1. name - > real-path

If the ‘-l’ option is given and the symbolic link refers to the actual directory, the tree will follow the symbolic link’s path as if it were a real directory.

The list of options
parameter describe
-d Only directories are listed.
-l If they point to directories, symbolic links are followed as if they were directories. When detected, symbolic links that would cause recursion are avoided.
-F Prints the full path prefix for each file.
-X Only the current file system is retained. Ala find -xdev.
-L Level Indicates the maximum display depth of a directory tree.
-R Recursively traverse down the tree of each level of directory (see the -l option) and execute the tree in each directory again adding ‘-o 00tree.html’ as a new option.
– P mode Only files that match the wildcard pattern are listed. Note: you must use the -A option to consider points “. The files at the beginning. Matching. Valid wildcard operators are “*” (any zero or more characters), “?” (any single character),[...]. '(any single character listed in parentheses (optional - - dashes) can be used in character ranges: ex: [AZ]) and[^…]. ‘(any single character not listed in parentheses) and “|” separate alternating pattern.
-i model Do not list files that match the wildcard pattern.
– ignore – case If the -p or -i options specify a matching pattern, this causes the pattern to match regardless of the case of each letter.
– matchdirs If the -p option specifies a matching pattern, it causes the pattern to be applied to the directory name (except the filename). If the directory names match, the match is disabled for the contents of the directory. If you use the — prune option, empty folders that match this pattern are not pruned.
– the prune Create a tree from the output to trim an empty directory, useful when used with -p or -i. For more information about this option, see the errors and comments below.
– noreport Ignore printing file and directory reports at the end of the tree list.
– the charset Charset Sets the character set to use for output HTML and drawing.
– filelimit # Do not download directories with multiple # entries.
– timefmt format Prints (implied -d) and formats the date according to a format string using strftime (3) syntax.
-o filename Send the output to the file name.
File options
parameter describe
-q Print non-printable characters in file names as question marks instead of default values.
-N Print unprintable characters as is, rather than escaped octal digits.
-Q Use double quotation marks to refer to file names.
-p Prints the file type and permissions for each file (according to ls -L).
-u Print the file’s username or UI # (if no username is available).
-G Print the group name of the file or GID# if no group name is available.
-s Prints the size and name of each file in bytes.
-H Print the size of each file in an easier to read manner, such as attaching kilobytes (K), megabytes (M), gigabytes (G), terabytes (T), gigabytes (P) and exabytes (E) size letters.
– si Like -h, but using SI units (powers of 1000).
– du For each directory report, the size is the cumulative size of all its files and subdirectories (and their files, etc.). The total amount of space used is also given in the final report (e.g. ‘du -c’ command). This option requires the tree to read the entire directory tree before being emitted, see errors and comments below. That means minus s.
-D Prints the date of the last time the time was changed or, if -c is used, lists the last state change of the listed files.
-F Append one for the directory/', to add one to the socket file= ‘, add one for the executable*', for a gate (Solaris) to add one> and a ` ‘|’ for FIFO, according to the ls – F
– inodes Prints the inode number of a file or directory
– device The id of the device to which the file or directory belongs is printed
Sorting options
parameter describe
-v Sort the output by version.
-t Sort the output by the time of the last modification rather than alphabetically.
-C Sort the output by the last state change rather than alphabetically. Modify the -d option (if used) to print the last status change instead of the change time.
-U Don’t sort. Lists the files in directory order. Disabled – dirsfirst.
-r Sort the output in reverse order. This is a kind of meta-sort that changes the above kind. Disable this option when using -u.
– dirsfirst List directories before files. This is a kind of meta-sort that changes the above kind. Disable this option when using -u.
– sort [=] Type Sort the output by type rather than name. Possible values include: ctime (-c), mtime (-t), size or version (-v).
Graphics options
parameter describe
– I, Leaves the tree unprintable, useful when used with the -f option. When used with the -j or -x options, as many Spaces as possible are also removed.
– a Turn on ANSI line graphic hacker when printing indentation lines.
-S Open CP437 line graphics (useful when using Linux console mode fonts). This option is now equivalent to ‘– charset = IBM437’ and may eventually depreciate.
-n Always turn off coloring, overridden by the -c option.
-C If the LS_COLORS or TREE_COLORS environment variables are not set, color is always turned on using the built-in color default. Use to color the output to the pipe.
XML/JSON/HTML options
parameter describe
-X Open XML output. Output the directory tree as an XML file.
-J Open JSON output. Output the directory tree as an array in JSON format.
-H baseHREF Open HTML output, including HTTP references. Useful for FTP sites. BaseHREF gives the base FTP location when using HTML output. That is, the local directory could be/ local/FTP/pub', but it must be referenced asftp://hostname.organization.domain/pub ‘(` baseHREF should be “ftp://hostname.organization.domain” tip: Do not use ANSI lines in this option, and do not provide multiple directories in the directory list. In addition to this option, use the -c option to force color output if you want to use color through CSS stylesheets.
-t title Set the title and H1 title string in HTML output mode.
– nolinks Close hyperlinks in THE HTML output.

reference

www.mankier.com/1/tree# – ig… Docs.microsoft.com/en-us/windo… Gnuwin32.sourceforge.net/packages/tr…

For code farmers, many project descriptions need to paste the directory structure (directory tree), manually write? Absolutely impossible

In fact, it is very simple, mainly using the tree command, Windows and Linux can be used

In Windows, run the tree command

It is also possible to use the tree command in CMD, the problem is that the parameters are not very many

By default, only the directory name is displayed

grammar
    
copy Copy successful!
  1. TREE [drive:] [path] [/F] [/A]

Arguments are case insensitive,/ a,/f are also acceptable

parameter describe
drive: Specifies the drive that contains the disk for which the directory structure is to be displayed
path Specifies the directory for which the directory structure is to be displayed
/F Displays the name of the file in each directory
/A Specifies that the tree will use text characters instead of graphic characters to display rows linking subdirectories
/? Displays help at a command prompt
    
copy Copy successful!
  1. D:\project\>tree /?
  2. Graphically displays the folder structure of a drive or pat
  3. TREE [drive:] [path] [/F] [/A]
  4. /F Display the names of the files in each folder.
  5. /A Use ASCII instead of extended characters.
  6. D:\project\>
Git used under

If you have Git installed on your Windows system, you can install the tree command under git_bash, and you can use many of the tree commands under git_bash

Install the tree in Git

To this address (gnuwin32.sourceforge.net/packages/tr… Binaries file

Then copy the tree.exe file in the bin directory to the usr/bin directory in the git installation directory, for example, C:\Program Files\ git \usr\bin

Git bash displays the secondary directory, ignoring node_modules and not displaying the file

    
    
  1. $ tree -L 2 -I "node_modules" -d
  2. .
  3. |-- app
  4. | |-- actions
  5. | |-- components
  6. | |-- constants
  7. | |-- containers
  8. | |-- dist
  9. | |-- reducers
  10. | |-- store
  11. | `-- utils
  12. |-- configs
  13. |-- dll
  14. |-- flow-typed
  15. | `-- npm
  16. |-- internals
  17. | |-- flow
  18. | |-- img
  19. | |-- mocks
  20. | `-- scripts
  21. |-- release
  22. |-- resources
  23. | `-- icons
  24. `-- test
  25. |-- actions
  26. |-- components
  27. |-- containers
  28. |-- e2e
  29. `-- reducers
  30. 27 directories

The tree command is used in Linux

Sudo yum -y install tree

Common commands

Display files and directories with maximum ‘num’ depth (where 1 indicates the current directory) :

    
  1. tree -L num

Display only directories:

    
  1. tree -d

Show hidden files at the same time:

    
  1. tree -a

Prints the tree without indentation, showing the full path (for -n without escaping Spaces and special characters) :

    
  1. tree -i -f

Print the size of each node next to it in human-readable format:

    
  1. tree -s -h

Filter trees using wildcard (GLOB) patterns:

    
copy Copy successful!
  1. tree -P *.txt

Ignore entries that match wildcard (glob) patterns:

    
  1. tree -I *.txt
grammar
    
  1. tree [-acdfghilnpqrstuvxACDFQNSUX] [-L level [-R]] [-H baseHREF] [-T title] [-o filename] [-nolinks] [-P pattern] [-I pattern] [-inodes] [-device] [-noreport] [-dirsfirst] [-version] [-help] [-filelimit #] [--si] [--prune] [--du] [--timefmt format] [--matchdirs] [--fromfile] [--] [directory ...]
describe

The tree is a recursive directory list of files generated by the program with depth indentation listed, which is colored ALA dircolors if the LS_COLORS environment variable is set and output is terminal. If there are no arguments, the tree lists the files in the current directory. When a directory argument is given, the tree lists in order all files and/or directories found in a given directory. After listing all the files/directories listed, the tree returns the total number of files and/or directories listed.

By default, when a symbolic link is encountered, the path referenced by the symbolic link is printed after the link name in the following format:

    
  1. name - > real-path

If the ‘-l’ option is given and the symbolic link refers to the actual directory, the tree will follow the symbolic link’s path as if it were a real directory.

The list of options
parameter describe
-d Only directories are listed.
-l If they point to directories, symbolic links are followed as if they were directories. When detected, symbolic links that would cause recursion are avoided.
-F Prints the full path prefix for each file.
-X Only the current file system is retained. Ala find -xdev.
-L Level Indicates the maximum display depth of a directory tree.
-R Recursively traverse down the tree of each level of directory (see the -l option) and execute the tree in each directory again adding ‘-o 00tree.html’ as a new option.
– P mode Only files that match the wildcard pattern are listed. Note: you must use the -A option to consider points “. The files at the beginning. Matching. Valid wildcard operators are “*” (any zero or more characters), “?” (any single character),[...]. '(any single character listed in parentheses (optional - - dashes) can be used in character ranges: ex: [AZ]) and[^…]. ‘(any single character not listed in parentheses) and “|” separate alternating pattern.
-i model Do not list files that match the wildcard pattern.
– ignore – case If the -p or -i options specify a matching pattern, this causes the pattern to match regardless of the case of each letter.
– matchdirs If the -p option specifies a matching pattern, it causes the pattern to be applied to the directory name (except the filename). If the directory names match, the match is disabled for the contents of the directory. If you use the — prune option, empty folders that match this pattern are not pruned.
– the prune Create a tree from the output to trim an empty directory, useful when used with -p or -i. For more information about this option, see the errors and comments below.
– noreport Ignore printing file and directory reports at the end of the tree list.
– the charset Charset Sets the character set to use for output HTML and drawing.
– filelimit # Do not download directories with multiple # entries.
– timefmt format Prints (implied -d) and formats the date according to a format string using strftime (3) syntax.
-o filename Send the output to the file name.
File options
parameter describe
-q Print non-printable characters in file names as question marks instead of default values.
-N Print unprintable characters as is, rather than escaped octal digits.
-Q Use double quotation marks to refer to file names.
-p Prints the file type and permissions for each file (according to ls -L).
-u Print the file’s username or UI # (if no username is available).
-G Print the group name of the file or GID# if no group name is available.
-s Prints the size and name of each file in bytes.
-H Print the size of each file in an easier to read manner, such as attaching kilobytes (K), megabytes (M), gigabytes (G), terabytes (T), gigabytes (P) and exabytes (E) size letters.
– si Like -h, but using SI units (powers of 1000).
– du For each directory report, the size is the cumulative size of all its files and subdirectories (and their files, etc.). The total amount of space used is also given in the final report (e.g. ‘du -c’ command). This option requires the tree to read the entire directory tree before being emitted, see errors and comments below. That means minus s.
-D Prints the date of the last time the time was changed or, if -c is used, lists the last state change of the listed files.
-F Append one for the directory/', to add one to the socket file= ‘, add one for the executable*', for a gate (Solaris) to add one> and a ` ‘|’ for FIFO, according to the ls – F
– inodes Prints the inode number of a file or directory
– device The id of the device to which the file or directory belongs is printed
Sorting options
parameter describe
-v Sort the output by version.
-t Sort the output by the time of the last modification rather than alphabetically.
-C Sort the output by the last state change rather than alphabetically. Modify the -d option (if used) to print the last status change instead of the change time.
-U Don’t sort. Lists the files in directory order. Disabled – dirsfirst.
-r Sort the output in reverse order. This is a kind of meta-sort that changes the above kind. Disable this option when using -u.
– dirsfirst List directories before files. This is a kind of meta-sort that changes the above kind. Disable this option when using -u.
– sort [=] Type Sort the output by type rather than name. Possible values include: ctime (-c), mtime (-t), size or version (-v).
Graphics options
parameter describe
– I, Leaves the tree unprintable, useful when used with the -f option. When used with the -j or -x options, as many Spaces as possible are also removed.
– a Turn on ANSI line graphic hacker when printing indentation lines.
-S Open CP437 line graphics (useful when using Linux console mode fonts). This option is now equivalent to ‘– charset = IBM437’ and may eventually depreciate.
-n Always turn off coloring, overridden by the -c option.
-C If the LS_COLORS or TREE_COLORS environment variables are not set, color is always turned on using the built-in color default. Use to color the output to the pipe.
XML/JSON/HTML options
parameter describe
-X Open XML output. Output the directory tree as an XML file.
-J Open JSON output. Output the directory tree as an array in JSON format.
-H baseHREF Open HTML output, including HTTP references. Useful for FTP sites. BaseHREF gives the base FTP location when using HTML output. That is, the local directory could be/ local/FTP/pub', but it must be referenced asftp://hostname.organization.domain/pub ‘(` baseHREF should be “ftp://hostname.organization.domain” tip: Do not use ANSI lines in this option, and do not provide multiple directories in the directory list. In addition to this option, use the -c option to force color output if you want to use color through CSS stylesheets.
-t title Set the title and H1 title string in HTML output mode.
– nolinks Close hyperlinks in THE HTML output.

reference

www.mankier.com/1/tree# – ig… Docs.microsoft.com/en-us/windo… Gnuwin32.sourceforge.net/packages/tr…