Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!eng.ufl.edu!usenet.eel.ufl.edu!news.mathworks.com!uunet!newton.burton.frostburg.md.us!newton.burton.frostburg.md.us!not-for-mail From: brian@newton.burton.frostburg.md.us (Brian Burton) Newsgroups: comp.unix.bsd Subject: Re: Removing a file with a leading "-" in the name Date: 2 Mar 1995 22:05:49 -0500 Organization: none Lines: 49 Message-ID: <3j612d$63i@newton.burton.frostburg.md.us> References: <1995Feb20.023938.20960@rai.juice.or.jp> <3iedls$hks@ixnews3.ix.netcom.com> <3ij68m$39g@news.parc.xerox.com> <3ivijs$8c1@gyda.ifi.uio.no> NNTP-Posting-Host: newton.burton.frostburg.md.us In article <3ivijs$8c1@gyda.ifi.uio.no>, Øystein Aanrud <oysteiaa@ifi.uio.no> wrote: > >In article <3ij68m$39g@news.parc.xerox.com>, macleod@adoc.xerox.com (Peter MacLeod) writes: >> 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. >> >Why not look in 'man rm': > >SYNOPSIS > rm [ - ] [ -fir ] filename... > >OPTIONS > - Treat the following arguments as filenames `-' so > that you can specify filenames starting with a > minus. > >=> rm - -.rej should work just fine. > On some systems it does, but not on FreeBSD 2.0. You need to use -- instead of -.