터미널에서 작업을 하다보면 디렉토리 구조를 한 눈에 보고 싶을 때가 있다.
$ ls -R
맥이든 리눅스든
파일 및 디렉토리를 조회하는 list segments 유틸이 기본 설치되어 있으므로
아쉬운대로 ls -R
과 같이 recursive 옵션을 추가하여 사용하곤 한다.
하지만 뭔가 많이 아쉽다.
$ ls -R
404.html android/ blog/ lessons/ sitemap.txt
Gemfile archive.html categories.html pages.html tags.html
Gemfile.lock assets/ images/ rss.xml tools/
./android:
2015/
./android/2015:
09/ 10/
./android/2015/09:
20/ 21/ 28/
...
tree 설치
리눅스에서 즐겨 사용하던 tree 유틸리티를 맥에서 사용해 보자.
다음과 같이 패키지 매니져의 하나인 brew 를 사용하여 tree 유틸리티를 설치하자.
$ brew install tree
==> Downloading https://homebrew.bintray.com/bottles/tree-1.7.0.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring tree-1.7.0.el_capitan.bottle.1.tar.gz
🍺 /usr/local/Cellar/tree/1.7.0: 7 files, 128K
다른 패키지 매니져를 사용하여 설치해도 된다.
$ sudo port install tree
또는
$ fink install tree
tree 맛보기
설치가 완료되었으면 아무 위치에서나 tree 만 입력해 보자.
복잡한 sub directory 구조까지 깔끔하게 tree 모양으로 잘 정리해 보여준다.
$ tree
.
├── 404.html
├── Gemfile
├── Gemfile.lock
├── History.markdown
├── android
│ └── 2015
│ ├── 09
│ │ ├── 20
│ │ │ └── navigating-up
│ │ │ └── index.html
...
├── archive.html
├── assets
│ ├── pygments-styles
...
└── tools
...
└── 2015
└── 12
└── 24
└── using-a-tree-utility-on-mac
└── index.html
94 directories, 128 files