TBH this is probably more suited to one of the other .SE's, either Unix &Linux, Ask Different, or even SuperUser. Which is why I assume you've been downvoted. That said...
The Short Answer
The answer is rm -r ./--crm
, or better yet, rmdir ./--crm
.
The Real Answer
On OS X you're usually using Bash in the terminal, which is important to know: which shell you use helps determine the syntax of the basic statements that let you manipulate files and directories, which includes renaming, removing, or calling on the kernel to execute them.
Along with man rm
, take a few days to read through man bash
and learn some of the concepts there.
Aside from this, it's a convention for most Unix command-line programs to run with specific arguments which follow the command. Some are obvious and work by passing data to the program. For instance, by running rm myfile
, you call the kernel to run the unlinking program on the file myfile
. Other arguments act like a set of switched to turn certain options on or off. These, sometimes known as 'flags', instead of passing data control the behavior of the program itself. For instance, rm -h
will remove nothing, but instead prints a short block of helpful text.
So the problem with removing a file with an unusual name, is that the program doesn't know how to interpret it. Throwing characters at it doesn't help either, and can get you into trouble.
Using Bash: Why It Didn't Work
Bash (your shell) interprets anything in single quotes literally, by stripping the quotes and taking the contents as-is. So by running rm '--crm'
, you're effectively running the same thing as rm --crm
. Bash specifically treats *
as a special character, doing something we call 'globbing': before the programs you called is run, Bash will expand the argument to every matching pathname you specified. In effect, if you have in your directory
~$ ls
--crm dummy.txt file.crm
and then run rm *crm
, Bash will first expand this, and then run the expanded version:
~$ rm --crm file.crm
...so you run the risk of destroying all your files ending in 'crm', plus it simply interprets the first directory as a flag again.
Using Bash: What Does Work
What Bash needs to know, and all it needs to know, in order to treat your directory as a file to be removed, is what rm
always needs: an explicit, fully qualified pathname. For most normal files, like myfile
above, Bash is smart enough to know you normally mean the current working directory— the one you can change into, or out of, with cd
. There are two special characters devoted to helping manage this. cd ..
for instance will take you to the directory 'above' your current one. If you're in /Users/foobar, and you run cd ..
, you'll move to /Users. Similarly, there's also the character denoting the current directory, which is simply .
. Running cd .
will take you... To the directory you're already in. Seems useless, doesn't it?
But this gives us a method of telling Bash exactly where your unfortunately-named directory lives: in the current directory .
lives the file --crm
, so you can specify it, and remove it, using rm ./--crm
— well, specifically this is a directory, and so you have to tell rm
to descend and recurse through the directory, and remove everything it finds there, first. You do this with the -r
flag: hence, rm -r ./--crm
.
A final caveat: now that I've tried to explain all this, I hope you also understand the serious danger in running rm -r -f /
. You should never use the -f
flag unless you know what you're doing.
man rm
in a terminal and read. – yoonix Jun 06 '16 at 20:25