Answers:
您只需为-I
命令提供所有模式,以分隔即可|
。从联机帮助页:
-P pattern
List only those files that match the wild-card pattern. Note:
you must use the -a option to also consider those files begin‐
ning 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.
因此,例如
tree -I 'test*|docs|bin|lib'
跳过“ docs”,“ bin”和“ lib”目录,名称中带有“ test”的任何目录,无论它们位于目录层次结构中的何处。显然,您可以应用通配符进行更强大的匹配。
docs/subdoc/
排除子目录?
tree --prune -P '*.html'
您也将获得目录,但是只有其中包含.html
文件的目录。