C.J.
> I have this file named "-\" and I cannot get rid of it.
> ...
> rm thinks that the \ is an option and it doesn't know how to handle it.
Read what follows before using.
rm -- -\\
You are the not the first to discover this, nor will this be the last
time that you hit this dilemna, nor rm the only command with which you
encounter it. (This is a classic test used to identify non unix gurus.)
Your shell (bash(1)) and getopt(3), not rm(1), thinks (-\) is an option.
You can control the splitting of arguments with (")s and (') as you indicated
but you still need to pass an argument (the filename) that begins with (-) .
rm like virtually all unix commands uses getopt(3) implementing the ANSI
option processing. rm passes getopt(3) a list of acceptable options and
whether or not each takes an argument. Each argument is tested in turn.
The end of the options is marked by
an argument that does not begin with (-) and
does not immediately follow an option that takes an argument,
an argument that is (--).
The above incomplete description of getopt(2) gives you several methods to
handle files with names containing special characters.
rm other filenames -\\ # other does not begin with (-) and thus
# nothing after it is an option
rm -- -\\ # nothing after (--) is an option
rm ./-\\ # ./-\\ refers to the same file but does
# not begin with (-)
cd ..; rm dir/-\\; cd dir # safer
mv ./-\\ RMme; rm RMme # safer
Your choice of method will depend on the particular command and circumstances.
With reversible commands (e.g. cat, ls, mv), ./<special-filename> is
probably the most commonly used method.
With rm, cp and other non-reversible commands, the best method is usually
to mv(1) the file(s) to a filename without special characters, or use them
from a parent directory. In general you should avoid using rm with
wildcards in the current or a parent directory. (Consider the effect of an
accidental blank: rm -r . /-\\ * .o # Do not try this in a directory
you care about)
Hope this helps,
--
Robert Meier
Keep your ear to the grindstone, your nose to the ground, take the bull by
the horns of a dilemma, and stop mixing metaphors.
-- unknown
FANUC Robotics North America, Inc. [EMAIL PROTECTED]
Voice: 1-248-377-7469 Fax: 1-248-377-7363