功能:树状结构输出目录和文件
安装
Mac
brew install tree
Linux
apt-get install tree
参数
显示出隐藏的文件
.env
-a 显示.开头的隐藏文件,但不显示 . 和 ..
tree -a bootstrapbootstrap└── cache└── .env
只列出目录
-d
tree -d bootstrapbootstrap└── cache
指定的目录递归层级
-L n level
tree -L 1 bootstrapbootstrap├── app.php└── cache
显示文件大小
-s 字节格式显示
-h 以人类可读的大小输出
—du 子目录大小包含了所有文件
tree -h -du bootstrapbootstrap├── [1.6K] app.php└── [ 16K] cache├── [1.7K] packages.php└── [ 14K] services.phptree -h bootstrapbootstrap├── [1.6K] app.php└── [ 160] cache├── [1.7K] packages.php└── [ 14K] services.phptree -s bootstrapbootstrap├── [ 1620] app.php└── [ 160] cache├── [ 1757] packages.php└── [ 14692] services.php
显示目录前缀
-f
tree -f bootstrpbootstrap├── bootstrap/app.php└── bootstrap/cache├── bootstrap/cache/packages.php└── bootstrap/cache/services.php
正则过滤
-P “正则”
tree -P "*s.php" bootstrpbootstrap└── bootstrap/cache├── bootstrap/cache/packages.php└── bootstrap/cache/services.php
输出到文件
-o
tree -o file.txt pathortree path >> file.txt
