Protection from "rm *"

Jonathan I. Kamens jik at athena.mit.edu
Tue Oct 2 05:17:26 AEST 1990


In article <1034 at bilver.UUCP>, bill at bilver.UUCP (Bill Vermillion) writes:
|> Now however, I can't seem to figure how to get rid of the -i.  I have tried
|> all variations of quotes, backslashes, wildcards.

  Read the monthly Frequently Asked Questions posting in comp.unix.questions. 
The last version was posted on September 6.  The FIRST QUESTION answered by
that posting is, "How do I remove a file whose name begins with a `-' ?"

  Here's the answer it provides:

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".

  Also, the man page for "rm" usually mentions the "--" or "-" option.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.misc mailing list