*BSD News Article 42831


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!news.clark.edu!sun.lclark.edu!news.reed.edu!usenet.ee.pdx.edu!insosf1.infonet.net!solaris.cc.vt.edu!news.mathworks.com!news.alpha.net!uwm.edu!cs.utexas.edu!howland.reston.ans.net!pipex!sunic!umdac!cs.umu.se!dvlsas
From: dvlsas@cs.umu.se (Sebastian Andersson)
Subject: Re: Removing a file with a leading "-" in the name
Message-ID: <D4GE5w.AqL@cs.umu.se>
Sender: news@cs.umu.se (News Administrator)
Organization: Dept. of Computing Science, Umea Univ., 901 87  Umea, Sweden
References: <1995Feb20.023938.20960@rai.juice.or.jp> <3iedls$hks@ixnews3.ix.netcom.com>
Date: Thu, 23 Feb 1995 12:46:39 GMT
Lines: 47

In article <3iedls$hks@ixnews3.ix.netcom.com>,
Lisa B. <lisab@ix.netcom.com> wrote:
>In <1995Feb20.023938.20960@rai.juice.or.jp> tetsuji@rai.juice.or.jp 
>(Tetsuji Rai) writes: 
>
>>
>>
>>Hi all,
>> The title says it all.   I wonder how to remove a file with "-" in the
>>begining of file name (such as "-foo").   You must not program for 
>that.
>>Simply use unix commands.   I just made a file "-.rej" by mistake, and
>>wondering how to erase it without programming.  Somehow rm recognizes
>>"-" character as an option.
>>
>>-Tetsuji
>>
>
>use a back slash    rm \-.rej
>
>the back slash "tells" the terminal emulation that the next char is to 
>be used as a char, not as a ....

Yes, this had worked if the character was a control character to the
shell, but - is a control character to the command rm and to escape it
from the shell serves no purpose.

The correct way to do this is:
rm - -.rej

The first - character tells rm that it is the end of options and the rest
of the line is filenames.

>
>PS: Watch out for trying to back space after a back slash.  The back 
>space becomes part of the string you are typing.

And no, this is nothing to watch out for (not in any shell I've used anyway).
What you might had in mind was to write something like ctrl-v back-space
in csh and tcsh.

>
>JACKB

/Sebastian
-- 
Play DUMII at dum.ts.umu.se 2001  DISCLAIMER: Pepsi, the Devil, made me do it.