No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help
View Responses


Grex Info Item 109: Exorcising the file *really* from Hell.
Entered by srw on Sun Feb 13 17:53:38 UTC 1994:

People have put blanks and other strange characters into file names
since the beginning of unix. Removing these "files from hell" can
usually be handled simply by saying rm -i *, or more spcifically specifying
the match pattern to cut down on the number of files seen.

Anyway, i have now created a file named -modems, and this appears to
be an "rm -i"-resistant strain of the "file from hell" genre.

The shell happily globs the * in rm -i *, but rm still thinks
-modem is an option and not a file name. Does anyone have experience
in exorcising a demon such as this?

10 responses total.



#1 of 10 by gregc on Sun Feb 13 18:21:25 1994:

2 posibilitys. You could try:
rm "\-modem"

or
rm ?modem


#2 of 10 by gregc on Sun Feb 13 18:23:26 1994:

Duh! Forget what I said in the last item. (brain siezure)
This will work:
rm ./-modem


#3 of 10 by scg on Sun Feb 13 20:22:58 1994:

What about "rm "-modem""?


#4 of 10 by gregc on Sun Feb 13 20:46:30 1994:

nope.


#5 of 10 by davel on Mon Feb 14 00:46:45 1994:

Steve, the reason for using quotes would be that the shell was interpreting
characters in the filename (such as ? or *) and generating something other
than what you wanted.  That's not the case here.  The problem here is that
rm sees the - at the beginning of the filename and thinks it's an option.
Greg's solution in #2 will work, but there's another solution followed by
rm & some other programs (on this system and lots of others): the special
parameter -- signals to the program that there are no more options, and
that everything else following is a real parameter.  So you could do
rm -i -- -modem      or
rm -i -- -*          which the shell would expand to the same thing unless
                     you have other files with names beginning -

(But   rm -- -i   would cause rm to look for a file named -i and delete that.)



#6 of 10 by remmers on Mon Feb 14 01:15:19 1994:

I suspect the -- option is special to the GNU version of rm, which is
what we seem to be running here.


#7 of 10 by gregc on Mon Feb 14 01:30:22 1994:

Well, yes and no. "--" is part of the POSIX specification. The gnu version
of rm is currently the only rm on here that follows the POSIX spec.
I forgot about "--". <gregc hangs head>


#8 of 10 by davel on Mon Feb 14 03:56:08 1994:

Aha.  I knew that the official standards on the SysV environment I'm familiar
with specify -- for this for all new software, but didn't know it was POSIX.
Not surprised, though.

Greg, no need to feel guilty, for heaven's sake.  The only reason I added
the entry about -- in addition to your working solution is that it *is*
the current standard, often working in other programs, even when the
parameter beginning with - may not be a filename.  The ./-modem wouldn't
work in that case.  For rm it's not only just fine, but the easiest solution
(and the one in the Unix FAQ, I think).


#9 of 10 by srw on Mon Feb 14 06:22:29 1994:

Thanks all. The -- was the magic incantation I needed to exorcise this
demon. 

Re #5: It took me a minute to figure out you were addressing scg.
Thanks for the --. It's not anything I ever could have guessed.

Re #2: Now *that* I should have been able to figure out. Duh. Thanks.


#10 of 10 by davel on Mon Feb 14 11:37:40 1994:

Sorry.  There are too many Steves (and a STeve) around, I guess.  8-{)>

Response not possible - You must register and login before posting.

No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss