最後更新: 2024-07-03
目錄
Extended glob pattern
Syntax
?(pattern): Matches zero or one occurrence of the given pattern. *(pattern): Matches zero or more occurrences of the given pattern. +(pattern): Matches one or more occurrences of the given pattern. @(pattern): Matches one occurrence of the given pattern. !(pattern): Matches anything except the given pattern.
Enable
shopt -s extglob
應用
[1] To remove all folders except the one named "en"
cd /usr/share/locale
# enable extended globbing
shopt -s extglob
# "!(en)" is an example of an extended glob pattern
rm -r !(en)