Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


yikes | 18 comments | Create New Account
Click here to return to the 'yikes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
yikes
Authored by: jpkelly on Oct 14, '02 10:45:32PM

I once created a directory by accident thaat began with a "-" I could not delete the #%@$ thing!
Short of gasoline and a match I was tearing my hair out trying to get rid of it.
(not to mention I was trying to impress my roomate with my unix skills on his machine)
I forget what I did to get rid of it.
Perhaps I booted into 9 and trashed it.



[ Reply to This | # ]
deleting a file starting with a hyphen
Authored by: colin on Oct 15, '02 05:43:44AM

the command to remove a file starting with a hyphen is 'rm -- file' the -- switches off the flags so that the filename you type is treated as a filename rather than a switch.



[ Reply to This | # ]
deleting a file starting with a hyphen
Authored by: hayne on Oct 15, '02 10:01:55AM

An easier way (also useful for deleting files with spaces in their names, etc.) is to put the filename in double-quotes. For example:
rm "-i"
would remove the file which is the subject of this hint.



[ Reply to This | # ]
deleting a file starting with a hyphen
Authored by: SeanAhern on Oct 15, '02 03:33:05PM

Nope, that wouldn't work. All the quotes would do is tell the shell that -i is one word. To the rm binary, "-i" and -i look the same.

Believe me, I've tried stuff like this before.

Other ways to do it, though:

rm ./-i
rm -- -i



[ Reply to This | # ]