Server Fault is a question and answer site for system and network administrators. 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

An application created a directory called "-123456" in my /tmp directory.

In Bash, rm -rf * returns: bash: cd: -7: invalid option

rm -rf "-123456" Same thing.


share|improve this question
Don't let this happen! What is the application? – Charles Stewart Apr 6 '10 at 9:33
@Charles Stewart: Something proprietary from IBM; I can't prevent it. – Dean J Apr 27 '10 at 16:06
You might think of filing a bug report to IBM about this: this is something like bedwetting. – Charles Stewart Apr 28 '10 at 11:23
up vote 10 down vote accepted

Use "--" to end your list of arguments. Thus: rm -rf -- -123456

share|improve this answer

Have you tried rm -rf ./-123456?

Edit: Works for me

# ls -l
total 1
drwxr-xr-x 2 root root 4096 Mar 29 20:48 -test
# rm -rf ./-test
# ls -l
total 0
share|improve this answer
You're right as well. Two paths to the same thing. – Bill Weiss Mar 29 '10 at 21:04
However! What if the file was named "something -12345"? :) – Bill Weiss Mar 30 '10 at 16:39
Easy (Sorry, can't format comments very well): $ touch something\ -12345 $ ls so* something -12345 $ rm something\ -12345 $ ls so* ls: so*: No such file or directory – Bryan Mar 31 '10 at 6:55

Classic basic UNIX puzzle. A more obtuse approach that manages to drag perl into it:

perl -e 'unlink "-12345"'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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