Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am just curious. Is there a save guard there? . and .. is a "subdirectory" of the directory we are deleting right?

I know it's not a subdirectory but linux treat it as a file with directory property.

share|improve this question

1 Answer 1

up vote 20 down vote accepted

This is not a part of rm, but a part of your shell. * is a glob which your shell expands and passes to rm in the form of arguments (rm never sees a literal *, unless the glob didn't match anything, in which case a literal * is passed). Standard * globs do not expand to include filenames beginning with a dot, which includes . and ... For example:

$ tee foo bar baz .foo .bar .baz < /dev/null
$ echo *
bar baz foo
$ echo .*
. .. .bar .baz .foo
share|improve this answer
In bash, shopt -s dotglob will cause dotfiles to be matched. Other shells probably have similar features. – jordanm Jan 25 '13 at 5:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.