Liunx system command tree command details

  • 2020-05-14 05:52:14
  • OfStack

introduce

The tree command, which means "tree" in English, creates a list of files and lists all the files in the directory as a tree. Is a command that takes precedence over ls in appearance level.

The tree command in linux is not installed by default. Let's take a look at the tree installation

Installation method


tar -zxvf tree-1.7.0.tgz
cd tree-1.7.0
make
cp -af tree /usr/bin

or


yum install -y tree

tree command details

-a displays all files and directories.

-A displays a tree using ASNI drawing characters instead of combining ASCII characters.

-C adds color to file and directory listings to make it easier to distinguish between types.

-d shows the directory name instead of the content.


[root@oracle01 /]# tree -d /data/mysqldata3306
/data/mysqldata3306
 ├ ─ ─  binlog
 ├ ─ ─  innodb_log
 ├ ─ ─  innodb_ts
 ├ ─ ─  log
 ├ ─ ─  mydata
 │    ├ ─ ─  mysql
 │    ├ ─ ─  performance_schema
 │    ├ ─ ─  test
 │    └ ─ ─  ym
 ├ ─ ─  relaylog
 ├ ─ ─  sock
 └ ─ ─  tmpdir

-D lists when a file or directory has changed.

-f displays the full relative path name before each file or directory.

- F in executable files, directories, Socket, symbolic links, pipeline name names, their combined with "*", "/", "=", "@", "|".

-g lists the group name of the file or directory to which it belongs. If there is no corresponding name, the group identifier is displayed.

-i does not list file or directory names in a stepped form.

-I < Sample style > Does not display file or directory names that match the template style.

-l if you encounter a directory that is a symbolic link, list directly the original directory to which the link points.

-n does not color file and directory listings.

-N lists file and directory names directly, including control characters.

-p lists permissions.


[root@oracle01 /]# tree -dCp /data/mysqldata3306
/data/mysqldata3306
 ├ ─ ─  [drwxr-xr-x] binlog
 ├ ─ ─  [drwxr-xr-x] innodb_log
 ├ ─ ─  [drwxr-xr-x] innodb_ts
 ├ ─ ─  [drwxr-xr-x] log
 ├ ─ ─  [drwxr-xr-x] mydata
 │    ├ ─ ─  [drwx------] mysql
 │    ├ ─ ─  [drwx------] performance_schema
 │    ├ ─ ─  [drwx------] test
 │    └ ─ ─  [drwx------] ym
 ├ ─ ─  [drwxr-xr-x] relaylog
 ├ ─ ─  [drwxr-xr-x] sock
 └ ─ ─  [drwxr-xr-x] tmpdir

-P < Sample style > Only the file or directory names that match the template style are displayed.

- q use "& # 63;" Number instead of control character, lists file and directory names.

-s lists file or directory sizes.


[root@oracle01 /]# tree -s /data/mysqldata3306/binlog/
/data/mysqldata3306/binlog/
 ├ ─ ─  [   65302] mysql-bin.000001
 ├ ─ ─  [  1046158] mysql-bin.000002
 ├ ─ ─  [    556] mysql-bin.000003
 ├ ─ ─  [    1125] mysql-bin.000004
 ├ ─ ─  [    1510] mysql-bin.000005
 ├ ─ ─  [   30019] mysql-bin.000006
 └ ─ ─  [    264] mysql-bin.index
0 directories, 7 files

-t sorts files and directories by the date of change, starting at the latest.


[root@oracle01 ym]# ll
total 220
-rw-rw---- 1 mysql mysql  61 Aug 18 14:01 db.opt
-rw-rw---- 1 mysql mysql 8556 Aug 18 17:04 s.frm
-rw-rw---- 1 mysql mysql 98304 Aug 18 17:04 s.ibd
-rw-rw---- 1 mysql mysql 8556 Aug 18 16:36 t.frm
-rw-rw---- 1 mysql mysql 98304 Aug 18 16:36 t.ibd
[root@oracle01 ym]# tree -t /data/mysqldata3306/mydata/ym/
/data/mysqldata3306/mydata/ym/
 ├ ─ ─  s.ibd
 ├ ─ ─  s.frm
 ├ ─ ─  t.ibd
 ├ ─ ─  t.frm
 └ ─ ─  db.opt

-u lists the owner name of a file or directory, and displays the user id number if there is no corresponding name.

-x limits the scope to the current file system. If some subdirectory under the specified directory is located on another file system, the subdirectory is excluded from the search scope.

conclusion

The above is the whole content of this article, I hope the content of this article to your study or work can bring 1 definite help, if you have questions you can leave a message to communicate.


Related articles: