根据bash的手册页:
GLOBIGNORE
A colon-separated list of patterns defining the set of filenames
to be ignored by pathname expansion. If a filename matched by a
pathname expansion pattern also matches one of the patterns in
GLOBIGNORE, it is removed from the list of matches.
但是在实践中...
$ bash --noprofile --norc
bash-4.2$ touch .bar
bash-4.2$ echo .*
. .. .bar
bash-4.2$ GLOBIGNORE=.
bash-4.2$ echo .*
.bar
为什么..从比赛列表中删除?据我所知,模式
.不匹配..,是吗?
GLOBIGNORE仅忽略.并且..采用无斜杠模式,并且GLOBIGNORE过滤文件路径而不是文件名。GLOBIGNORE=.; echo .*将不包含.nor..,但GLOBIGNORE=.; echo ./.*(或echo /bin/.*)将包含!要忽略.并..从所有的水珠,它看起来像你需要shopt -s extglob和GLOBIGNORE='?(*/)@(.|..)'。