Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.