【mac】安装tree命令

tree命令

用于生成目录的树形层级结构,比如下图:

.
├── alicelmxblog
│   ├── __init__.py
│   ├── config.py
│   ├── controllers
│   │   ├── __init__.py
│   │   └── bolg.py
│   ├── forms.py
│   ├── models.py
│   ├── static
│   │   ├── css
│   │   └── js
│   └── templates
│       ├── base.html
│       ├── home.html
│       └── post.html
├── fake_data.py
└── manage.py

安装

使用homebrew,如果你还没有安装就点这里吧,中文的哦,很友好。。
在终端中输入:

$ brew install tree

常用技巧

  1. 我们可以在目录遍历时使用 -L 参数指定遍历层级
tree -L 2
  1. 如果你想把一个目录的结构树导出到文件 Readme.md ,可以这样操作
tree -L 2 >README.md //然后我们看下当前目录下的 README.md 文件
  1. 只显示文件夹;
tree -d 
  1. 显示项目的层级,n表示层级数。例:显示项目三层结构,tree -l 3;
tree -L n
  1. tree -I pattern 用于过滤不想要显示的文件或者文件夹。比如要过滤项目中的node_modules文件夹;
tree -I “node_modules”

猜你喜欢

转载自blog.csdn.net/alicelmx/article/details/81188389