tree コマンド便利
tree コマンド便利ですよね.
$ tree . . ├── bar │ └── 000.txt ├── baz │ └── 000.txt └── foo ├── 000.txt └── 001.txt 3 directories, 4 files
イイ感じで階層を表示してくれるので, README とかに貼る際に重宝していますです.
ということで, 本案件で扱う環境の情報は下記の通り.
$ sw_vers ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G19009 $ tree --version tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
で, 本題
tree コマンドで一部のディレクトリやファイルは表示されないようにしたい
以下のように -I
オプションを利用します.
$ tree . -I bar . ├── baz │ └── 000.txt └── foo ├── 000.txt └── 001.txt 2 directories, 3 files
|
で区切れば複数パターンの指定が可能です.
$ tree . -I 'foo|bar' . └── baz └── 000.txt 1 directory, 1 file $ tree . -I '001*' . ├── bar │ └── 000.txt ├── baz │ └── 000.txt └── foo └── 000.txt 3 directories, 3 files
LGTM.
以上
man 案件でした.
$ man tree ... 略... -P pattern List only those files that match the wild-card pattern. Note: you must use the -a option to also consider those files beginning with a dot `.' for matching. Valid wildcard operators are `*' (any zero or more characters), `?' (any single character), `[...]' (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and `[^...]' (any single character not listed in brackets) and `|' separates alternate patterns. -I pattern Do not list those files that match the wild-card pattern. ... 略...