Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Unix: Files starting with a dash, -

On my OSX (10.6.4) machine, I somehow managed to create a directory called "-v9" in the /var/root directory. How do I delete this directory?

Using the backslash to escape the minus doesn't seem to work:

# rm -r \-v9
rm: illegal option -- 9

Even using a wildcard won't work:

# rm -ri *9
rm: illegal option -- 9
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

I tried to delete it using the Finder, but ran into a different problem. Because it's in the /var/root directory, the Finder won't display the contents of the folder. At least, it doesn't do this by default, and I don't know how to enable it (ditto for Path Finder).

share|improve this question

marked as duplicate by quack quixote Jun 22 '10 at 19:13

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.

2 Answers 2

up vote 10 down vote accepted

rm -rf ./-v9 or rm -rf -- -v9

share|improve this answer
    
The -- is a neat trick. –  Lorin Hochstein Jun 22 '10 at 18:36

How about sudo rm -rf /var/root/-v9?

Alternatively, check out the HiddenFiles Widget, that let's you inspect the contents of hidden folders.

Edit:

  1. I just found out Finder won't let you look in /var/root, due to permissions - it is owned by System.
  2. /var is actually a shortcut to /private/var, so the above bash command should probably read sudo rm -rf /private/var/root/-v9
  3. Use these suggestions at your own risk, by the way ;-)

Edit #2: If you use the absolute path to your folder, it doesn't matter that it starts with a '-' (at least on my mac). However, if you first cd into the relevant directory and type rm -rf -v9 then rm interprets the -v9 part as an (illegal) argument passed to it.

Cheers

share|improve this answer

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