Getting rid of a file called "-d" [duplicate]

rm -- -d

-- means "end of options". Anything further on the command line following this is interpreted as an argument (i.e. the file name in your case), and not an option.


rm ./-d

is the answer to your question.


Using '--' is by far the easiest in this specific case. However, a more general solution if you stumble across a file with unprintable control characters is to reference the file by inode:

% ls -ali aFileWithFunnyCharacters
      9215 -rw-r-----   1 chris  chris         0 Sep  8 16:55 aFileWithFunnyCharacters
% find . -xdev -inum 9215 -exec rm {} \;
% ls -ali aFileWithFunnyCharacters
aFileWithFunnyCharacters: No such file or directory