Unix: Delete files starting with a dash

Sometimes you accidently create files like -c:

-rw-r--r-- 1 root root 329 Dec 11 08:59 -c

When you try to view, edit or delete them, the dash confuses the actual program:


Use the -- operator:

vi -- -c

The -- switch will tell the shell there are no more arguments for this execution.

(Featured image taken from trilug.org.)

Leave a Reply

Your email address will not be published. Required fields are marked *