Com o bash, a configuração da variável GLOBIGNORE special é um valor não vazio que é suficiente para ignorar . e .. ao expandir globs. De os documentos do Bash :
The
GLOBIGNOREshell variable may be used to restrict the set of filenames matching a pattern. IfGLOBIGNOREis set, each matching filename that also matches one of the patterns inGLOBIGNOREis removed from the list of matches. If thenocasegloboption is set, the matching against the patterns inGLOBIGNOREis performed without regard to case. The filenames.and..are always ignored whenGLOBIGNOREis set and not null. However, settingGLOBIGNOREto a non-null value has the effect of enabling the dotglob shell option, so all other filenames beginning with a‘.’ will match.
Se o definirmos como .:.. , tanto . como .. serão ignorados. Como configurá-lo para qualquer coisa não-nula também obterá esse comportamento, podemos defini-lo como apenas .
Então:
GLOBIGNORE=.
rm -rf .*