Add new comment
How to remove a file in unix with a leading dash in it's name?
Submitted by pwnell on Sun, 01/17/2010 - 10:33That was the question I asked myself recently when I had a file called --exclude in the root of my filesystem. These commands all failed:
rm --exclude rm "--exclude" rm \-\-exclude rm ??exclude
So I found the solution - so simple it embarrassed me. Just add the full path:
rm /--exclude
or tell the command line parser to stop interpreting options:
rm -- --exclude
Easy!
Read It Or Don't.