Brevis esse laboro, Obscurus fio -- I strive to be brief, and I become obscure.     CEE UCL HelpDesk Homepage

Department of Civil and Environmental Engineering
Frank Batten College of Engineering and Technology
Old Dominion University
Norfolk, Virginia 23529-0241, USA
Tel) (757) 683-3753
Fax) (757) 683-5354


	
Return to CEE UCL HelpDesk Homepage
CEE UCL HelpDesk Access Counter
 
How do I remove a file whose name begins with a "-" ?


  

Normally a dash "-" indicates a start of flag(s)/option(s) to a command, i.e., "ls -al." Problem is that you can also [accidently] name a file beginning with a dash, let's say, "-abc.txt." In this case, normal "rm" command won't delete this file when you type "rm -abc.txt" since "rm" command sees and treats "-abc.txt" as a flag(s)/option(s) to the "rm" command.

To delete such files, figure out some way to name the file so that it doesn't begin with a dash. The simplest answer is to use

$ rm ./-filename

(assuming "-filename" is in the current directory, of course) This method of avoiding the interpretation of the "-" works with other commands too.

Alternative is that many commands accept a "- -" argument which means "this is the last option, anything after this is not an option." Give a try following;

$ rm -- -filename


Return to CEE UCL HelpDesk Homepage Move to the Top of this page