*BSD News Article 42866


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!news.ysu.edu!usenet.ins.cwru.edu!howland.reston.ans.net!agate!biosci!parc!dunvegan!macleod
From: macleod@adoc.xerox.com (Peter MacLeod)
Newsgroups: comp.unix.bsd
Subject: Re: Removing a file with a leading "-" in the name
Date: 23 Feb 1995 23:37:58 GMT
Organization: Xerox Desktop Document Systems, Palo Alto, CA
Lines: 30
Distribution: world
Message-ID: <3ij68m$39g@news.parc.xerox.com>
References: <1995Feb20.023938.20960@rai.juice.or.jp> <3iedls$hks@ixnews3.ix.netcom.com>
NNTP-Posting-Host: dunvegan.adoc.xerox.com
X-Newsreader: TIN [version 1.2 PL2]

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
                      ^^^^^^^^^
This won't work.

You can say:

% rm ugh -.rej
rm: ugh: No such file or directory

but it will still remove "-.rej", at least on my workstation. "rm" doesn't
look for "-" after it sees a non "-" argument.

-- Peter