🎄
treeコマンドの使い方
treeコマンドでできること
- ターミナル上でディレクトリ構造を表示することが可能になる
- これにより人やGPTにディレクトリ構造を簡単に共有可能
例
$ tree
.
├── Cargo.lock
├── Cargo.toml
├── Makefile
├── README.md
├── run_on_wasabi.sh
├── rust-toolchain.toml
├── saba_core
│ ├── Cargo.toml
│ └── src
│ ├── lib.rs
│ └── url.rs
└── src
└── main.rs
インストール方法
$ brew install tree
オプション
-L (Level)
- 表示する階層の深さを指定可能
$ tree -L 1
.
├── Cargo.lock
├── Cargo.toml
├── Makefile
├── README.md
├── build
├── run_on_wasabi.sh
├── rust-toolchain.toml
├── saba_core
├── src
└── target
$ tree -L 2
.
├── Cargo.lock
├── Cargo.toml
├── Makefile
├── README.md
├── build
│ └── wasabi
├── run_on_wasabi.sh
├── rust-toolchain.toml
├── saba_core
│ ├── Cargo.toml
│ └── src
├── src
│ └── main.rs
└── target
├── CACHEDIR.TAG
├── release
└── x86_64-unknown-none
-I (pattern)
- パターンを指定して表示結果から除外
-
|
で複数指定可能
build
ディレクトリとtarget
ディレクトリを表示結果から除外する場合
$ tree -L 3 -I "build|target"
.
├── Cargo.lock
├── Cargo.toml
├── Makefile
├── README.md
├── run_on_wasabi.sh
├── rust-toolchain.toml
├── saba_core
│ ├── Cargo.toml
│ └── src
│ ├── lib.rs
│ └── url.rs
└── src
└── main.rs
Discussion