From: Richard Harry (richard@syma.sussex.ac.uk)
Date: 06/15/92


From: richard@syma.sussex.ac.uk (Richard Harry)
Subject: Re: How do I delete file named "-I" ?
Date: 15 Jun 1992 11:06:08 GMT

From article <1992Jun15.060243.23706@unislc.uucp>, by erc@unislc.uucp (Ed Carp):
> thoth@uiuc.edu (Ben Cox) writes:
>
>>jason@intrepid.ucr.edu (Jason Bishop) writes:
>
>>> Try rm - -I Leading - tells rm that there are no arguments, all following
>>> text are files to delete. Also works with cp, mv, etc...
>
>>Unfortunately, that doesn't work. "rm - -I" gives "rm: -: No such
>>file or directory". This is the standard answer to this question,
>>though, and I have never gotten it to work on any unix system. The
>>BSD manpage even says that this is the answer. It is not.
>
>>Yesterday, I thought I knew the answer to this question. Now I am
>>certain that I don't. :-( (Not even dired -- emacs doesn't even
>>notice the file is there; same with "rm ?I".)
>
> Try "rm -i *". If that doesn't work, I could post a short program
> I wrote once to delete unprintable files (ones that rm would barf on).
> Essentially, it would try to delete anything that came in on stdin. I
> would do a "ls -1 > xxx", edit xxx, then do a "rmstdin < xxx".

From the unix FAQ ( comp.unix.???? )

1) How do I remove a file whose name begins with a "-" ?
       
    Figure out some way to name the file so that it doesn't
    begin with a dash. The simplest answer is to use

            rm ./-filename

    (assuming "-filename" is in the current directory, of course.)
    This method of avoiding the interpretation of the "-" works
    with other commands too.

    Many commands, particularly those that have been written to use
    the "getopt(3)" argument parsing routine, accept a "--" argument
    which means "this is the last option, anything after this is not
    an option", so your version of rm might handle "rm -- -filename".
    Some versions of rm that don't use getopt() treat a single "-"
    in the same way, so you can also try "rm - -filename".