mac 터미널에서 폴더트리 구조 확인
Contents
<사진: unsplash>
windows에서는 cmd에서 폴더트리가 바로 나오는것 같던데 macOS의 터미널에서는 따로 tree를 설치해야 볼 수 있다.
아래 명령어로 brew를 통해 설치
$ brew install tree
사용법
기본적인 사용법은 작업중인 폴더로 가서 tree
라고만 입력하면 된다.
$ tree
폴더 제외
그런데 node project와 같이 node_module
이라던가, dist
폴더가 있는 구조에서는 불필요하게 많은 폴더가 출력됨을 볼 수 있다.
폴더를 제외하고 싶을 땐, tree -I <diretory>
로 명령하면 해당 폴더를 제외하고 출력 가능하다.
예시> 하나의 폴더 제외
$ tree -I node_module
예시> 두 개의 폴더 제외
$ tree -I node_module -I dist
// 또는 아래와 같이
$ tree -I 'node_modules|dist'
폴더만 출력
파일은 제외하고 폴더만 출력하고 싶다면 -d
를 옵션으로 사용할 수 있다.
$ tree -d
파일은 제외하고 모든 폴더를 출력한다.
숨겨진 파일 출력
.env
와 같은 파일처럼 .
으로 시작하는 파일이나 숨겨진 파일의 경우 -a
를 입력하여 출력할 수 있다.
$ tree -a
실사용 예시
$ tree -a -I 'node_modules|dist|coverage|.idea|.github|.git|http-client'
이렇게 입력하면 아래와 같이 볼 수 있는데 막상 적고보니 좀… 번거롭긴 하다.
.
├── .env_sample
├── .eslintrc
├── .gitignore
├── .prettierrc
├── babel.config.js
├── db
│ ├── erd
│ │ └── erd.dbml
│ └── migrations
│ └── 20230117191810_table_set_up.sql
├── env
│ ├── .env.dev
│ ├── .env.production
│ └── .env.test
├── jest.config.js
├── package-lock.json
├── package.json
├── src
│ ├── app.ts
│ ├── controllers
│ │ └── users.controller.ts
│ ├── entities
│ │ ├── category.entity.ts
│ │ ├── comment.entity.ts
│ │ ├── estimation.entity.ts
│ │ ├── feed.entity.ts
│ │ ├── feedStatus.entity.ts
│ │ ├── feedSymbol.entity.ts
│ │ ├── feedUploadFiles.entity.ts
│ │ ├── symbol.entity.ts
│ │ ├── uploadFiles.entity.ts
│ │ └── users.entity.ts
│ ├── main.ts
│ ├── middleware
│ │ └── jwt.strategy.ts
│ ├── models
│ │ ├── index.ts
│ │ ├── repositories.ts
│ │ └── users.dao.ts
│ ├── routes
│ │ ├── index.route.ts
│ │ └── users.route.ts
│ ├── services
│ │ └── users.service.ts
│ ├── tests
│ │ ├── setup-tests.ts
│ │ └── users.test.ts
│ ├── types
│ │ └── global.d.ts
│ └── utils
│ └── util.ts
└── tsconfig.json
tree options
usage: tree [-acdfghilnpqrstuvxACDFJQNSUX] [-L level [-R]] [-H baseHREF]
[-T title] [-o filename] [-P pattern] [-I pattern] [--gitignore]
[--gitfile[=]file] [--matchdirs] [--metafirst] [--ignore-case]
[--nolinks] [--hintro[=]file] [--houtro[=]file] [--inodes] [--device]
[--sort[=]<name>] [--dirsfirst] [--filesfirst] [--filelimit #] [--si]
[--du] [--prune] [--charset[=]X] [--timefmt[=]format] [--fromfile]
[--fflinks] [--info] [--infofile[=]file] [--noreport] [--version]
[--help] [--] [directory ...]
------- Listing options -------
-a All files are listed.
-d List directories only.
-l Follow symbolic links like directories.
-f Print the full path prefix for each file.
-x Stay on current filesystem only.
-L level Descend only level directories deep.
-R Rerun tree when max dir level reached.
-P pattern List only those files that match the pattern given.
-I pattern Do not list files that match the given pattern.
--gitignore Filter by using .gitignore files.
--gitfile X Explicitly read gitignore file.
--ignore-case Ignore case when pattern matching.
--matchdirs Include directory names in -P pattern matching.
--metafirst Print meta-data at the beginning of each line.
--prune Prune empty directories from the output.
--info Print information about files found in .info files.
--infofile X Explicitly read info file.
--noreport Turn off file/directory count at end of tree listing.
--charset X Use charset X for terminal/HTML and indentation line output.
--filelimit # Do not descend dirs with more than # files in them.
-o filename Output to file instead of stdout.
------- File options -------
-q Print non-printable characters as '?'.
-N Print non-printable characters as is.
-Q Quote filenames with double quotes.
-p Print the protections for each file.
-u Displays file owner or UID number.
-g Displays file group owner or GID number.
-s Print the size in bytes of each file.
-h Print the size in a more human readable way.
--si Like -h, but use in SI units (powers of 1000).
--du Compute size of directories by their contents.
-D Print the date of last modification or (-c) status change.
--timefmt <f> Print and format time according to the format <f>.
-F Appends '/', '=', '*', '@', '|' or '>' as per ls -F.
--inodes Print inode number of each file.
--device Print device ID number to which each file belongs.
------- Sorting options -------
-v Sort files alphanumerically by version.
-t Sort files by last modification time.
-c Sort files by last status change time.
-U Leave files unsorted.
-r Reverse the order of the sort.
--dirsfirst List directories before files (-U disables).
--filesfirst List files before directories (-U disables).
--sort X Select sort: name,version,size,mtime,ctime.
------- Graphics options -------
-i Do not print indentation lines.
-A Print ANSI lines graphic indentation lines.
-S Print with CP437 (console) graphics indentation lines.
-n Turn colorization off always (-C overrides).
-C Turn colorization on always.
------- XML/HTML/JSON options -------
-X Prints out an XML representation of the tree.
-J Prints out an JSON representation of the tree.
-H baseHREF Prints out HTML format with baseHREF as top directory.
-T string Replace the default HTML title and H1 header with string.
--nolinks Turn off hyperlinks in HTML output.
--hintro X Use file X as the HTML intro.
--houtro X Use file X as the HTML outro.
------- Input options -------
--fromfile Reads paths from files (.=stdin)
--fflinks Process link informtion when using --fromfile.
------- Miscellaneous options -------
--version Print version and exit.
--help Print usage and this help message and exit.
-- Options processing terminator.