rm cannot delete files starting with "--" [duplicate] rm cannot delete files starting with "--" [duplicate] shell shell

rm cannot delete files starting with "--" [duplicate]


The usual trick is

rm ./--1355509766.jpg

Update: here's what man rm has to say about this:

To  remove a file whose name starts with a '-', for example '-foo', useone of these commands:       rm -- -foo       rm ./-foo


Use -- to separate options from parameters.

$ rm -- --1355509766.jpg

This works with other commands too. For example:

$ touch -- -v         # create a file called -v$ grep foo -- -v      # grep for "foo" in file called -v


Try file name with path:

$ rm ./--file.name

Example:

$ echo dgag > --test.txt$ ls--test.txt$ rm ./--test.txt$ ls