shell command --tree

shell command --tree

0, tree command exclusive map bed

Click here to quickly open the article [ map bed _shell command tree ]

1, indicating that the function of the command tree

treeTree command is used to list all the contents of the specified directory, including all files, subdirectories, and so on.

Syntax 2, tree command

SYNOPSIS
    tree  [-acdfghilnpqrstuvxACDFQNSUX]  [-L level [-R]] [-H baseHREF] [-T title] [-o file‐
    name] [--nolinks] [-P pattern] [-I pattern] [--inodes] [--device] [--noreport] [--dirs‐
    first]  [--version] [--help] [--filelimit #] [--si] [--prune] [--du] [--timefmt format]
    [directory ...]

3. Option Description tree command

  • -a: show all files, including hidden files
  • -d: show only directory
  • -f: displays the full path to each file
  • -i: do not show branches, common parameters used in conjunction with -f
  • -L level: traversing the directory maximum number of layers, level positive integer greater than 0
  • -F: In the end of the file plus a variety of different types represented by

4, hands-tree command

Check for tree command

rpm -qa tree  -->查询tree命令是否安装,显示则已经安装,若未安装,执行以下操作
yum install tree -y  -->使用yum,进行安装tree命令
LANG=en_US.UTF-8  -->临时调整系统字符集,防止树形显示乱码

Example 1: no arguments execute treecommand

cd && rm -rf /test  -->将之前的实验环境删除掉。提示:rm -rf 谨慎使用!
mkdir -p /test/dir{1..2}  -->模拟环境,创建目录
touch /test/dir{1..2}/file{1..2}  -->模拟环境,创建文件
cd /test/
tree  -->不加参数

Example 2: in a tree structure display all the contents of the directory ( -afunction)

touch .file  -->点(.)开头的是隐藏文件
tree -a  -->以 . 开头的文件都显示出来
tree  -->对比以下

Example 3: list only (root directory structure of the first level -Lfunctions)

tree -L 1  -->加参数的结果
tree  -->对比以下

Example 4: display all directories only (not display file)

mkdir dir1/sub{1..2}
touch dir1/sub{1..2}/{1..2}.txt
tree -d dir1  --> -d 只显示目录
ls -l dir1
ls -l dir1/sub1/

Example 5: Use the treecommand to distinguish between directories and files method (commonly used)

tree -L 2 -F  -->如果是目录的话后面加/
tree -L 2 -F |grep /$  -->过滤以斜线结尾的所有内容
tree -L 2 -d  -->使用 -d参数只显示目录树

"MineGi something to say": Come and sweep the two-dimensional code link below, and join us!

Guess you like

Origin www.cnblogs.com/MineGi/p/12171565.html