Deleting file named "-file"

Deleting file named "-file"

Post by Jack » Sun, 23 Jan 2000 04:00:00



How can I delete a file with a minus sign in front of it?

ie.    -file

All I get is "illegal option" errors when trying all my various attempts.

Thanks

Chris

 
 
 

Deleting file named "-file"

Post by Barry Margoli » Sun, 23 Jan 2000 04:00:00




>How can I delete a file with a minus sign in front of it?

>ie.    -file

>All I get is "illegal option" errors when trying all my various attempts.

You read the FAQ rather than start the zillionth rehash of this thread in
the past year.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Deleting file named "-file"

Post by Alexander L » Mon, 24 Jan 2000 04:00:00


Well, when you use rm -file to remove a file. The rm command will think that
the -file is an argument. try using
rm '-file' to remove the file. Although I never try this but it works when I
"cd" to a directory which named
-current. Hope that can be help.




>>How can I delete a file with a minus sign in front of it?

>>ie.    -file

>>All I get is "illegal option" errors when trying all my various attempts.

>You read the FAQ rather than start the zillionth rehash of this thread in
>the past year.

>--

>GTE Internetworking, Powered by BBN, Burlington, MA
>*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
>Please DON'T copy followups to me -- I'll assume it wasn't posted to the

group.
 
 
 

Deleting file named "-file"

Post by Thomas Jesperse » Mon, 24 Jan 2000 04:00:00



> How can I delete a file with a minus sign in front of it?

> ie.    -file

rm -- -file

look at 'man rm':  (taken from IRIX system)

NOTES
  A -- permits the user to mark explicitly the end of any command line
  options, allowing rm to recognize filename arguments that begin with
  a -.

 
 
 

Deleting file named "-file"

Post by Chris Costell » Mon, 24 Jan 2000 04:00:00



> try using rm '-file' to remove the file.

   It won't work.  Quotes only affect spaces and shell expansion
(among a few minor non-related other things).  See the FAQ for
the correct answer.


 
 
 

Deleting file named "-file"

Post by Ken Pizzi » Mon, 24 Jan 2000 04:00:00




>>You read the FAQ rather than start the zillionth rehash of this thread in
>>the past year.

Which advice is proptly ignored, as we see the ever popular
_wrong_ answer immediately flare up:

Quote:>Well, when you use rm -file to remove a file. The rm command will think that
>the -file is an argument. try using
>rm '-file' to remove the file. Although I never try this

Okay, all together now:
  * Placing an argument in quotes protects the argument from
    further interpretation by the shell, but does not change
    how the program interprets the argument.
  * The problem with "-file" and "rm" is that rm is seeing
    an option list of the "-f" flag, the "-i" flag, and an
    unrecognized "-l" flag (followed either by an unknown "-e"
    flag or a "e" argument to the "-l" flag).
  * To prevent rm from seeing the - as introducing an option,
    rather than something that just happens to be the first
    character of a filename, there are two popular solutions to
    this:
      . change the spelling of the pathname you pass to rm;
        instead of simply specifying "-file", specify "./file"
        or `pwd`/file
      . if you have a "modern" version of rm, use the "I'm
        trying to be a standard, dammit" option "--", telling
        rm to stop interpreting options, the remaing arguments
        are to be interpreted the same regardless of whether or
        not they begin with a "-".

As Barry said: Read The FAQ!

                --Ken Pizzini

 
 
 

Deleting file named "-file"

Post by Christopher J. Matter » Thu, 27 Jan 2000 04:00:00



> Well, when you use rm -file to remove a file. The rm command will think that
> the -file is an argument. try using
> rm '-file' to remove the file. Although I never try this but it works when I

AAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHH!!!!!

Thank you.  I feel much better now.

Try rm ./-file, which will actually work, unlike the above.

                                   Chris Mattern