Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!samsung!rex!uflorida!gatech!udel!princeton!phoenix.Princeton.EDU!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul Falstad) Newsgroups: comp.unix.internals Subject: Re: I have a file named "-" Message-ID: <6661@idunno.Princeton.EDU> Date: 27 Feb 91 04:39:56 GMT References: <22834@hydra.gatech.EDU> <1991Feb26.170212.22920@convex.com> Sender: news@idunno.Princeton.EDU Organization: The Royal Society For Putting Things On Top Of Other Things Lines: 64 tchrist@convex.COM (Tom Christiansen) wrote: >From the keyboard of gt2807a@prism.gatech.EDU (Benjamin H. Cowan): >: I have a file whose name consists of the single character "-". I can't >:rm it or mv it or cat it or more it or anything to it. How can I get rid of >:it? >Ask a coworker. > >Burn your computer. > >Throw out the disk. Ask a coworker!?! Please, please; let's at least answer the question before tempers get out of control. If you have a file that simply has a '/' in it, you can just quote the slash: rm "/" But a file with a - in it takes special handling. Fortunately there are many ways to remove a file like this. 1. Write a short C program: main() { rename("-",".nfsXXXX"); } Simply run this, and the - file will be renamed to a .nfsXXXX, which will probably be deleted by cron within a day. Slick huh? 2. (Even cooler) main() { struct timeval xx = { 0,0 }; rename("-","#foo#"); utimes("#foo#",&xx); } This will rename - to a file beginning with #, and date it Dec 31, 1969. The file will, again, probably be deleted by cron. 3. Tar up the whole directory and then remove it with rm -rf, then use a binary editor to change the name of the file to something else. Then untar it and delete it normally. 4. Use ls -i to get the inode of the file, and then ask the super-user to run clri on the inode, followed by fsck. 5. Get the source to rm, and remove all the option handling routines with #ifdefs. Then compile it and use the simpler version of rm to delete the file. There may be simpler ways but these should work although I haven't tested any of them. Hope this helps. ;-) -- Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD I think there should be more race prejudice. LESS race prejudice. Princeton University apologizes for the content of this article. Brought to you by Super Global Mega Corp .com