Answers:
简而言之,通配指的是模式匹配。Bash使用简单的globing之类的方法,将echo l*
其扩展到当前目录中以letter开头的文件列表l
。当然,您可以猜到,它很简单而且很有限。
输入extglob
。如您所料,它代表extended globbing
。此选项允许更高级的模式匹配。来自man bash
:
extglob If set, the extended pattern matching features described
above under Pathname Expansion are enabled.
在此之前:
If the extglob shell option is enabled using the shopt builtin, several
extended pattern matching operators are recognized. In the following
description, a pattern-list is a list of one or more patterns separated
by a |. Composite patterns may be formed using one or more of the
following sub-patterns:
?(pattern-list)
Matches zero or one occurrence of the given patterns
*(pattern-list)
Matches zero or more occurrences of the given patterns
+(pattern-list)
Matches one or more occurrences of the given patterns
@(pattern-list)
Matches one of the given patterns
!(pattern-list)
Matches anything except one of the given patterns
extglob
可以使用多种方法。Linux Journal和Greg的wiki中提供了很多很好的示例。