rm cannot delete files starting with “--” [duplicate]

独自空忆成欢 提交于 2019-12-03 16:15:02

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', use
one 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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!