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.
Asked
Active
Viewed 5,460 times
1
-
@ChrisDown right – daisy Feb 10 '14 at 06:31
1 Answers
5
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
Chris Down
- 125,559
- 25
- 270
- 266