|
|
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.
2 posibilitys. You could try: rm "\-modem" or rm ?modem
Duh! Forget what I said in the last item. (brain siezure) This will work: rm ./-modem
What about "rm "-modem""?
nope.
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.)
I suspect the -- option is special to the GNU version of rm, which is what we seem to be running here.
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>
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).
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.
Sorry. There are too many Steves (and a STeve) around, I guess. 8-{)>
Response not possible - You must register and login before posting.
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss