1

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.

derobert
  • 109,670
Alex
  • 245
  • 1
  • 3
  • 6

1 Answers1

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