Take the 2-minute tour ×
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.

This question already has an answer here:

I am about to enter the command: rm -r * in a directory where I would like all files and directories (and their files) removed. My concern is that unix also has the ./ and the ../ directories. rm -r should follow all directories: does that mean it will follow ../ and delete stuff in higher up directories? I can't seem to find the answer to this by googling.

share|improve this question

marked as duplicate by terdon, slm, Mat, Anthon, Zelda Feb 10 '14 at 6:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@ChrisDown right –  warl0ck Feb 10 '14 at 6:31

1 Answer 1

up vote 5 down vote accepted

POSIXly, * does not expand to include . and .. (or any filename beginning with a dot) unless you actually explicitly include it using options specific to your shell (eg. dotglob in bash).

It's "safe" (unless any of your files start with a dash, in which case you should use rm -- *), assuming that's what you mean to do, but you will not delete files with filenames starting with a dot.

Might I suggest that you do this instead:

cd .. && rm -r directory
share|improve this answer
good suggestion, will use that instead. –  Alex Feb 10 '14 at 6:31

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