Super User is a question and answer site for computer enthusiasts and power users. 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 run the following command in Terminal on my OS X Snow Leopard laptop:

rm -rf /path/to/directory

Normally, this deletes the directory and all contents/subdirectories. For some reason, though, it now gives the following error message:

rm: –rf: No such file or directory
rm: /path/to/directory: is a directory

I'd be grateful if somebody could share why rm doesn't recognize '-rf' as an option string?

share|improve this question

migrated from Sep 11 '10 at 6:19

This question came from our site for professional and enthusiast programmers.

Voted to move to superuser. Stack Overflow is for programming questions. – jer Sep 11 '10 at 6:17

In your second "code" block, you're using instead of -.

The character you're using is not the - ASCII character that is used to prefix command line options, therefore –rf is interpreted as a file name.

Use rm -rf /path/to/directory.

share|improve this answer
Nice catch. The character in the quoted rm: –rf: No such file or directory message is U+2013 EN DASH, not the normal option introducing character U+002D HYPHEN-MINUS. Probably the result of copying and pasting some overzealously re-formatted text from a web page of some sort. – Chris Johnsen Sep 11 '10 at 6:35
You're absolutely right, thanks for the quick response! – Danny Goodman Sep 12 '10 at 9:57

Is rm aliased to something? rm will interpret -rf as a file name if it somehow has -- in the argument list, as in rm -- -rf /path/directory.

Try it with a backslash in front, which disables aliases. Or use the full path:

\rm -rf /path/directory
/bin/rm -rf /path/directory
share|improve this answer

Are you sure you're feeding it the correct path name? If it contains spaces, make sure you include quotation marks.

rm -rf "/my folder/here"
share|improve this answer

Just a random thing to try. Have you tried:

rm -r -f /path/to/directory
share|improve this answer

You must log in to answer this question.

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