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.

Help?

link|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
feedback

2 Answers

up vote 7 down vote accepted

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

link|improve this answer
feedback

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
link|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
feedback

Your Answer

 
or
required, but never shown

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