5

So my command line skills are a little rusty and I'm having trouble remembering the differences between the meanings of flags in different distro's os's. I also don't really remember all my technical lingo so manpages seem really unclear.

Basically I'm on Mac OS X and want to delete a directory along with all of its contents. What I'm mainly concerned about, I suppose, is that it'll delete literally ALL of the references within the directory, including ../ and ../<everything else, including ../'s own ../> and then just totally screw up my entire system.

Which of these do I want to run?

$ rm -R dir-name/

or

$ rm -r
1
  • 1
    Jon, please click the checkmark next to one of the responses if they answer your question. This will mark your problem solved and reward the person answering.
    – Daniel Beck
    Feb 25, 2011 at 21:30

3 Answers 3

8

If you want to delete foo/bar, the command you want is rm -r foo/bar (assuming you are working in the directory that contains foo). This will delete bar and everything in it, but leave foo and anything else in it alone.

rm -r is clever enough not to recurse into ../ - otherwise every rm -r would delete everything.

4

If you run:

rm -r

without passing it a directory/file argument, nothing will happen.

There is no difference between:

rm -r xyz
rm -R xyz
rm -r xyz/

etc.

0
0

You could also add -f if you don't want prompting for confirmation:

rm -rf xyz

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .