目次
説明
treeコマンドは、ディレクトリのファイル構造をツリー図の形式で一覧表示します。
文法
tree [-d] <dir>
パラメータ名 | 説明 |
-d | 表示された構造にはディレクトリ名のみが保持されます |
使用例
ディレクトリ構造を表示する
ツリー<ディレクトリ名>を使用して、ディレクトリのファイル構造を取得します。
$ tree FlaskDemo
FlaskDemo
├── render_demo.py
└── templates
├── for.html
└── hello_world.html
1 directory, 3 files
ディレクトリ名のみを保持する
-dパラメーターを使用すると、treeコマンドの表示結果はディレクトリー名のみを保持します。
$ tree FlaskDemo/ -d
FlaskDemo/
└── templates
1 directory
予防
指定されたディレクトリ名は存在しません
構造を表示するために指定されたディレクトリ名が存在しない場合、treeコマンドは「erroropeningdir」を表示します。
$ tree fun
fun [error opening dir]
0 directories, 0 files
非ディレクトリタイプを指定します
treeコマンドは、ディレクトリのファイル構造のみを表示できます。指定した名前がディレクトリタイプでない場合、ツリーには「エラーオープニングディレクトリ」と表示されます。
$ tree auto.sh
auto.sh [error opening dir]
0 directories, 0 files