Имеется переменная GLOBIGNORE. Из man 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.
Итак, простой способ - просто установить GLOBGINORE на указанное имя файла:
$ touch {a,b,c,d}.png
$ echo *.png
a.png b.png c.png d.png
$ GLOBIGNORE=c.png
$ echo *.png
a.png b.png d.png
Итак, в вашем случае: [ ! d3]
GLOBIGNORE=filename.gif; rm *.gif
Конечно, поскольку GLOBIGNORE содержит шаблоны, вы можете использовать его всякий раз, когда хотите исключить шаблон:
$ GLOBIGNORE='[a-c].png'; echo *.png
d.png
$ touch bd.png; GLOBIGNORE='?.png'; echo *.png
bd.png
Преимущество (?!) of GLOBIGNORE заключается в том, что настройка man bash не согласована и позволяет dotglob:
The GLOBIGNORE shell variable may be used to restrict the set of file‐
names matching a pattern. If GLOBIGNORE is set, each matching filename
that also matches one of the patterns in GLOBIGNORE is removed from the
list of matches. The filenames ``.'' and ``..'' are always ignored
when GLOBIGNORE is set and not null. However, setting GLOBIGNORE to a
non-null value has the effect of enabling the dotglob shell option, so
all other filenames beginning with a ``.'' will match. To get the old
behavior of ignoring filenames beginning with a ``.'', make ``.*'' one
of the patterns in GLOBIGNORE. The dotglob option is disabled when
GLOBIGNORE is unset.
Итак, простой способ удаления всех файлы и папки в каталоге:
GLOBIGNORE=.; rm -r *
* будет соответствовать именам файлов, начинающимся с ., поскольку GLOBIGNORE включен dotglob, но он не будет соответствовать . или [ f20], поэтому вы не будете влиять на родительский каталог таким образом.