Back
Featured image of post [mac] tree 명령어

[mac] tree 명령어

디렉토리 구조 뽑아오는 방법

tree?

가끔 개발하다보면 특정 프로젝트의 구조나 디렉토리 구조를 설명할 일이 있는데 홈브류에 tree라는 패키지가 있어 소개해보려한다.

tree 패키지 설치하기

Homebrew에서 아래 명령어로 tree를 설치한다.

brew install tree

기본 사용법

터미널에서 원하는 디렉토리로 간다음 tree를 입력하면 해당 디렉토리 구조가 출력된다.
아래는 이 블로그의 content 디렉토리의 구조를 출력한 결과.

{22-04-17 18:49}sjchoi-MackBook-Pro:~/Mydoc/blog/jinyisland/content@master✗✗✗✗✗✗ user% tree
.
├── assets
│   ├── etc
│   │   └── etc.png
│   ├── java
│   │   └── java.png
│   ├── js
│   │   ├── algorithm-search.png
│   │   ├── callstack_1.png
│   │   ├── callstack_2.png
│   │   ├── callstack_3.png
│   │   ├── callstack_4.png
│   │   ├── datatypes.png
│   │   ├── eo.png
│   │   ├── heap-and-binary.png
│   │   ├── heap-sort.png
│   │   ├── js-eventloop.png
│   │   ├── js.png
│   │   ├── node-rest-api.jpg
│   │   └── this-types.png
│   ├── title.png
│   ├── ts
│   │   └── ts.png
│   ├── vue
│   │   └── vue.png
│   └── web
│       ├── http-cookie.png
│       ├── visit.png
│       └── web.png
├── categories
│   ├── book
│   │   ├── _index.md
│   │   └── book_thumb.jpg
│   ├── etc
│   │   ├── _index.md
│   │   └── etc_thumb.jpg
│   ├── javascript
│   │   ├── _index.md
│   │   └── js_thumb.jpg
│   ├── typescript
│   │   ├── _index.md
│   │   └── ts_thumb.jpg
│   ├── ui
│   │   ├── _index.md
│   │   └── ui_thumb.jpg
│   ├── vue
│   │   ├── _index.md
│   │   └── vue_thumb.jpg
│   └── web
│       ├── _index.md
│       └── web_thumb.jpg
├── contents
├── page
│   ├── about.md
│   ├── archives.md
│   └── search.md
└── post
    ├── etc
    │   └── mac-tree.md
    ├── java
    │   └── java-array.md
    ├── javascript
    │   ├── algorithm-heap.md
    │   ├── algorithm-search.md
    │   ├── arrow-function.md
    │   ├── eventloop.md
    │   ├── express-routing.md
    │   ├── express-start.md
    │   ├── js-closure.md
    │   ├── js-datatype.md
    │   ├── js-function.md
    │   ├── js-loop.md
    │   ├── js-overview.md
    │   ├── let-const.md
    │   ├── middleware.md
    │   ├── module.md
    │   ├── node-file.md
    │   ├── node-restapi.md
    │   ├── npm.md
    │   ├── promise-async-await.md
    │   ├── template-literals.md
    │   └── useful-modules.md
    ├── ui
    │   └── font.md
    ├── vue
    │   ├── component.md
    │   ├── computed-watch.md
    │   ├── prettier.md
    │   ├── project-import.md
    │   ├── vue-router.md
    │   ├── vue-start.md
    │   ├── vue-tailwind.md
    │   └── vuex.md
    └── web
        ├── http-cookies.md
        └── hugo-ga.md

24 directories, 71 files

특정 디렉토리 제외

이 포스트를 쓰게된 결정적인 계기인데.. node에서 node_modules라는 패키지 디렉토리를 제외하고 싶었다.
-I옵션을 사용하면된다.

tree -I node_modules