LoginSignup
1
3

More than 3 years have passed since last update.

ディレクトリ構成を簡単に表示!treeコマンド(Mac)よく使うオプションも紹介

Posted at

はじめに

今回はディレクトリの構造を簡単に表示できるtreeコマンドの紹介をしたいと思います。

├── Docker/
│   ├── App/
│   │   ├ 000-default.conf  
│   │   ├ Dockerfile
│   │   └ php.ini 
│   └── DB/
│        ├ my.cnf  
│        └ volume/ 
│
├── src/ 
└── docker-compose.yml

導入完了するとこのようにディレクトリの構成がターミナル上から確認できます。これで手打ちする必要がなくなりますね。

treeコマンドのインストール

brewコマンドが実行できるかを確認します。

[Mac]$ brew -v

問題なければ

[Mac]$ brew install tree

を実行します。

インストール完了後は、任意のディレクトリで

[Mac]$ tree 

と入力するといい感じにディレクトリの構成が表示できます。

オプションの紹介

-aオプション

[Mac]$ tree -a

これで隠しファイルを表示できます。

-Lオプション

[Mac]$ tree -L 1 

階層の深さを指定できます。

上記の二つを組み合わせてみると

[Mac]$ tree -L 1 -a
.
├── .coveralls.yml
├── .devcontainer
├── .dockerignore
├── .editorconfig
├── .env
├── .env.dist
├── .env.install
├── .git
├── .github
├── .gitignore
├── .gitmodules
├── .htaccess
├── .php_cs.dist
├── .scrutinizer.yml
├── .travis.yml
├── COPYING
├── Dockerfile
├── LICENSE.txt
├── Procfile
├── README.md
├── app
├── app.json
├── appveyor.yml
├── bin
├── codeception
├── codeception.sh
├── codeception.yml
├── composer.json
├── composer.lock
├── docker-compose.yml
├── dockerbuild
├── eccube4
├── gulp
├── gulpfile.js
├── html
├── index.php
├── maintenance.php
├── nginx.conf.sample
├── package-lock.json
├── package.json
├── phpunit.xml.dist
├── robots.txt
├── src
├── symfony.lock
├── test.txt
├── tests
├── var
├── vendor
└── web.config

このようになります。

-dオプション

ディレクトリだけ表示したい場合は-dをつけます。

[Mac]$ tree -d 
.
├── app
│   ├── Customize
│   │   ├── Controller
│   │   ├── Entity
│   │   └── Resource
│   │       ├── config
│   │       └── locale
│   ├── DoctrineMigrations
│   ├── Plugin
│   │   ├── AnnotatedRouting
│   │   │   ├── Controller
│   │   │   └── Resource
│   │   │       └── template
│   │   ├── EntityExtension
│   │   │   └── Entity
│   │   ├── EntityForm
│   │   │   ├── Entity
│   │   │   └── Form
│   │   ├── FormExtension
│   │   │   ├── Form
│   │   │   │   └── Extension
│   │   │   └── ServiceProvider
│   │   ├── HogePlugin
│   │   │   ├── Controller
│   │   │   └── Resource
│   │   │       └── template
│   │   ├── MigrationSample
│   │   │   ├── DoctrineMigrations
│   │   │   └── Entity
│   │   ├── PurchaseProcessors
│   │   │   └── Service
│   │   │       └── PurchaseFlow
│   │   │           └── Processor
│   │   └── QueryCustomize
│   │       ├── Repository
│   │       └── ServiceProvider
│   ├── PluginData
│   ├── config
│   │   └── eccube
│   │       ├── packages
│   │       │   ├── codeception
│   │       │   ├── dev
│   │       │   ├── install
│   │       │   ├── prod
│   │       │   └── test
│   │       └── routes
│   │           ├── dev
│   │           └── install
│   ├── proxy
│   │   └── entity
│   └── template
│       ├── admin
│       ├── default
│       ├── plugin
│       └── user_data
├── bin
├── codeception
│   ├── _data
│   │   └── plugins
│   ├── _envs
│   ├── _support
│   │   ├── Helper
│   │   ├── Interactions
│   │   ├── Page
│   │   │   ├── Admin
│   │   │   ├── Front
│   │   │   └── Install
│   │   └── _downloads
│   ├── acceptance
│   ├── functional
│   └── unit
├── dockerbuild
├── eccube4
├── gulp
│   ├── build
│   └── task
├── html
│   ├── plugin
│   ├── template
│   │   ├── admin
│   │   │   └── assets
│   │   │       ├── css
│   │   │       │   └── fileupload
│   │   │       ├── img
│   │   │       ├── js
│   │   │       │   └── vendor
│   │   │       │       ├── fileupload
│   │   │       │       │   └── vendor
│   │   │       │       └── jquery.ui
│   │   │       │           └── theme
│   │   │       │               └── images
│   │   │       ├── pdf
│   │   │       └── scss
│   │   │           ├── component
│   │   │           ├── library
│   │   │           └── mixin
│   │   ├── default
│   │   │   └── assets
│   │   │       ├── css
│   │   │       ├── icon
│   │   │       ├── img
│   │   │       │   ├── common
│   │   │       │   └── top
│   │   │       ├── js
│   │   │       └── scss
│   │   │           ├── component
│   │   │           ├── mixins
│   │   │           ├── project
│   │   │           └── sections
│   │   └── install
│   │       ├── assets
│   │       │   ├── css
│   │       │   ├── img
│   │       │   └── js
│   │       │       └── vendor
│   │       ├── css
│   │       ├── dist
│   │       │   ├── css
│   │       │   ├── fonts
│   │       │   └── js
│   │       └── img
│   │           └── common
│   ├── upload
│   │   ├── save_image
│   │   └── temp_image
│   └── user_data
│       └── assets
│           ├── css
│           ├── img
│           │   └── common
│           ├── js
│           └── pdf
├── src
│   └── Eccube
│       ├── Annotation
│       ├── Command
│       ├── Common
│       ├── Controller
│       │   ├── Admin
│       │   │   ├── Content
│       │   │   ├── Customer
│       │   │   ├── Order
│       │   │   ├── Product
│       │   │   ├── Setting
│       │   │   │   ├── Shop
│       │   │   │   └── System
│       │   │   └── Store
│       │   ├── Block
│       │   ├── Install
│       │   └── Mypage
│       ├── DataCollector
│       ├── DependencyInjection
│       │   └── Compiler
│       ├── Doctrine
│       │   ├── Common
│       │   │   └── CsvDataFixtures
│       │   │       └── Executor
│       │   ├── DBAL
│       │   │   └── Types
│       │   ├── EventSubscriber
│       │   ├── Filter
│       │   ├── ORM
│       │   │   ├── Mapping
│       │   │   │   └── Driver
│       │   │   └── Query
│       │   └── Query
│       ├── Entity
│       │   └── Master
│       ├── Event
│       ├── EventListener
│       ├── Exception
│       ├── Form
│       │   ├── DataTransformer
│       │   ├── EventListener
│       │   ├── Extension
│       │   ├── Type
│       │   │   ├── Admin
│       │   │   ├── Front
│       │   │   ├── Install
│       │   │   ├── Master
│       │   │   └── Shopping
│       │   └── Validator
│       ├── Log
│       │   └── Processor
│       ├── Plugin
│       ├── Repository
│       │   └── Master
│       ├── Request
│       ├── Resource
│       │   ├── doctrine
│       │   │   ├── import_csv
│       │   │   │   ├── en
│       │   │   │   └── ja
│       │   │   └── migration
│       │   ├── functions
│       │   ├── locale
│       │   └── template
│       │       ├── admin
│       │       │   ├── Content
│       │       │   ├── Customer
│       │       │   ├── Form
│       │       │   ├── Order
│       │       │   ├── Product
│       │       │   ├── Setting
│       │       │   │   ├── Shop
│       │       │   │   └── System
│       │       │   └── Store
│       │       ├── common
│       │       ├── default
│       │       │   ├── Block
│       │       │   ├── Cart
│       │       │   ├── Contact
│       │       │   ├── Entry
│       │       │   ├── Forgot
│       │       │   ├── Form
│       │       │   ├── Help
│       │       │   ├── Mail
│       │       │   ├── Mypage
│       │       │   ├── Product
│       │       │   └── Shopping
│       │       ├── install
│       │       ├── smartphone
│       │       └── toolbar
│       ├── Security
│       │   ├── Core
│       │   │   ├── Encoder
│       │   │   └── User
│       │   ├── Http
│       │   │   └── Authentication
│       │   └── Voter
│       ├── Service
│       │   ├── Calculator
│       │   ├── Cart
│       │   ├── Composer
│       │   ├── Payment
│       │   │   └── Method
│       │   └── PurchaseFlow
│       │       └── Processor
│       ├── ServiceProvider
│       ├── Session
│       │   └── Storage
│       │       └── Handler
│       ├── Twig
│       │   └── Extension
│       ├── Util
│       └── Validator
│           └── EmailValidator
├── tests
│   ├── Eccube
│   │   └── Tests
│   │       ├── Command
│   │       ├── Common
│   │       ├── DependencyInjection
│   │       │   └── Compiler
│   │       ├── Doctrine
│   │       │   ├── Common
│   │       │   │   └── CsvDataFixtures
│   │       │   │       └── Executor
│   │       │   ├── ORM
│   │       │   │   └── Tools
│   │       │   ├── Query
│   │       │   └── TimeZone
│   │       ├── Entity
│   │       │   └── Master
│   │       ├── Event
│   │       ├── EventListener
│   │       ├── Fixture
│   │       ├── Form
│   │       │   ├── EventListener
│   │       │   ├── Type
│   │       │   │   ├── Admin
│   │       │   │   ├── Front
│   │       │   │   ├── Install
│   │       │   │   └── Master
│   │       │   └── Validator
│   │       ├── Functions
│   │       ├── Mock
│   │       ├── Repository
│   │       │   └── Master
│   │       ├── Security
│   │       │   └── Voter
│   │       ├── Service
│   │       │   ├── Cart
│   │       │   ├── Payment
│   │       │   └── PurchaseFlow
│   │       │       └── Processor
│   │       ├── ServiceProvider
│   │       ├── Session
│   │       │   └── Storage
│   │       │       └── Handler
│   │       ├── Transaction
│   │       ├── Twig
│   │       │   └── Extension
│   │       ├── Util
│   │       └── Web
│   │           ├── Admin
│   │           │   ├── Content
│   │           │   ├── Customer
│   │           │   ├── Order
│   │           │   ├── Product
│   │           │   ├── Setting
│   │           │   │   ├── Shop
│   │           │   │   └── System
│   │           │   └── Store
│   │           ├── Block
│   │           ├── Install
│   │           └── Mypage
│   └── Fixtures
│       ├── import_csv
│       └── session
├── var
└── vendor

-sオプション

ファイルサイズを確認したいとき -s オプションをつけます。
-hオプションもさらにつけると単位がわかりやすくなります。

[Mac]$ tree -L 1 -a -sh
.
├── [  99]  .coveralls.yml
├── [  96]  .devcontainer
├── [  16]  .dockerignore
├── [ 965]  .editorconfig
├── [2.1K]  .env
├── [2.0K]  .env.dist
├── [  96]  .env.install
├── [ 448]  .git
├── [ 224]  .github
├── [1.1K]  .gitignore
├── [   0]  .gitmodules
├── [2.2K]  .htaccess
├── [ 845]  .php_cs.dist
├── [5.6K]  .scrutinizer.yml
├── [ 21K]  .travis.yml
├── [ 18K]  COPYING
├── [2.6K]  Dockerfile
├── [3.0K]  LICENSE.txt
├── [  51]  Procfile
├── [4.7K]  README.md
├── [ 320]  app
├── [1.1K]  app.json
├── [2.3K]  appveyor.yml
├── [ 192]  bin
├── [ 480]  codeception
├── [ 709]  codeception.sh
├── [ 298]  codeception.yml
├── [6.5K]  composer.json
├── [376K]  composer.lock
├── [1.7K]  docker-compose.yml
├── [ 128]  dockerbuild
├── [ 160]  eccube4
├── [ 160]  gulp
├── [ 135]  gulpfile.js
├── [ 192]  html
├── [2.7K]  index.php
├── [1.5K]  maintenance.php
├── [2.0K]  nginx.conf.sample
├── [216K]  package-lock.json
├── [1.1K]  package.json
├── [1.4K]  phpunit.xml.dist
├── [  32]  robots.txt
├── [ 128]  src
├── [ 16K]  symfony.lock
├── [   9]  test.txt
├── [ 256]  tests
├── [ 128]  var
├── [  64]  vendor
└── [4.5K]  web.config

14 directories, 35 files
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3