Wohl jeder Unix-Administrator hat schon einmal "ls *.txt" in einer Shell eingegeben, um sich nur Dateien anzeigen zu lassen, die auf ".txt" enden. Um alle Dateien anzuzeigen, die diesem Muster nicht entsprechen, bietet die Bash-Shell ein spezielles Feature namens "Ext(ended) Glob(bing)." Aktiviert wird es mit der Eingabe "shopt -s extglob". Anschließend lässt sich mit dem Ausrufezeichen, das sonst für andere Zwecke reserviert ist, das eingegebene Muster negieren. Im folgenden Beispiel enthält ein Verzeichnis vier Dateien:
> ls abar afoo bbar bfoo > ls a* abar afoo > ls !(b*) -bash: !: event not found
Aktiviert man nun mit "shop -s extglob" das Extended Globbing der Bash, funktioniert die Negation des Suchausdrucks wie gewünscht:
> shopt -s extglob > ls !(b*) abar afoo > ls !(a*) bbar bfoo > ls !(*foo) abar bbar
Die Eingabe von "shopt -u extglob" schaltet das Feature wieder ab. Das Reference Manual der Bash führt die mit Extglob aktivierten Sonderzeichen auf:
?(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.