Just how do I delete a documents whose name starts with "-" (hyphen a.k.a. dashboard or minus)?

Just how do you remove a documents whose filename starts with a dashboard (hyphen or minus) -? I'm ssh would certainly right into a remote OSX web server and also I have this documents in my directory site:

tohru:~ $ ls -l
total 8
-rw-r--r--    1 me  staff  1352 Aug 18 14:33 --help
...

Just how worldwide can I delete --help from a CLI? This concern is something that I find in various kinds on celebration, these files are very easy to create, yet hard to remove.

I have actually attempted making use of backslash

rm \-\-help

I have actually attempted quotes

rm "--help"

Just how do I protect against the minus (dashboard or hyphen) personality to be taken an alternative?

0
2019-05-04 03:33:32
Source Share
Answers: 3

The solutions of Vegar Nilsen and also edfuh are great and also the correct remedies to a trouble similar to this.

I do intend to add a basic feedback to this inquiry that permits you to delete any kind of documents with a hard documents name. First its inode number is gotten making use of ls -i or some kind of stat and afterwards the documents is gotten rid of by looking for documents in the existing directory site by inode number and also implementing the rm command on the documents with a coordinating inode number

find . -inode <inode> -exec rm {}\;

Since inode numbers are one-of-a-kind in each documents system you can remove any kind of documents utilizing this ; unicode or making use of retreat personalities. It is just how ever before really aggravating to type out so I would certainly advise including the line

TAB: menu-complete             # Tab: Cycles through the command
"\e[Z": menu-complete-backward # Shift-Tab: Cycles backwards

right into your .inputrc documents if you're making use of celebration. This permits you to cycle via the checklist of feasible conclusions (for further information).

0
2019-05-10 22:33:48
Source

Use "--" to make rm stop analyzing command line options, similar to this :

rm -- --help
.
0
2019-05-08 01:24:53
Source

Or you can do

rm ./--help
.
0
2019-05-08 01:02:13
Source