One shell command a day Linux text operation series tree command


The tree command is the main role of printing files and directories in a graphical tree structure. Usually, this command is not included in Linux distributions. You need to use the package manager to install it yourself.


1. tree

Print all files in the current directory

2. tree –p ${dir}

Print all the files in the dir directory and their permissions

3. tree –h ${dir}

Print all the files in the dir directory and the size suitable for reading

4. tree path –P “*.sh”

Print all files ending in. Sh

5. tree path –H http://localhost –o out.html

HTML file containing the output of the directory tree

Interpretation — help

usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]]
     [-P pattern] [-I pattern] [-o filename] [–version] [–help] [–inodes]
     [–device] [–noreport] [–nolinks] [–dirsfirst] [–charset charset]
     [–filelimit #] [<directory list>]
   – a             List of all files
  – d             It’s just a catalog
  – l             Symbolic links like directories
  – f             Print the full path prefix for each file
   – i             Do not print indentation lines
  – q             Print non printable characters as?
  – N             Print the non printable character is
   – p             Print permissions for each file
  – u             Displays the file owner or uid
   – g             Displays the owner or GID of the file
   – s             Print the size of each file
  – h             Print file size in a more human readable way
   – D             Print last modified date
  – F             Add ‘/’, ‘=’, ‘*’ or ‘|’ as according to LS – F
   – v             Sort files alphanumeric
  – r             Arrange files in reverse alphanumeric order
  – t             Sort files by last time
  – x             Stay on current file system only
  – L level       Tracing level printing
  – A             Print pattern indentation line
  – S             Print character indentation line
  – n             Always turn off color (- C overlay)
   – C             Turn on color
  – P pattern     List only regular expressions
  – I pattern     Do not list regular expressions
  – H baseHREF    Prints out HTML format with baseref as top directory
  – T string      Replace the default HTML title and H1 header with string
  – R             Rerun tree when Max dir level reached
  – o file        Output to file instead of output stream
  — inodes       Print the number of nodes per file
  — device       Print device ID number to which each file belongs
  — noreport     Turn off file / directory count at end of tree listing
  — nolinks      Turn off hyperlinks in HTML output
  — dirsfirst    List directories before files
  — charset X    Use charset x for HTML and indentation line output
  — Filelimit # do not descend dirs with more than # files in them


1. –v –r

Arrange files in positive or reverse order according to letters and numbers

2. – L level or — filelimit#

It’s all the level of traceability

3. -x

Tree – x ${dir} only prints the current directory information

And file related (not file content related) the main operation is over, the weekend to do a little summary, and try to write some basic linux commands.

Recommended Today

Java Engineer Interview Questions

The content covers: Java, mybatis, zookeeper, Dubbo, elasticsearch, memcached, redis, mysql, spring, spring boot, springcloud, rabbitmq, Kafka, Linux, etcMybatis interview questions1. What is mybatis?1. Mybatis is a semi ORM (object relational mapping) framework. It encapsulates JDBC internally. During development, you only need to pay attention to the SQL statement itself, and you don’t need to […]