如何删除以双连字符开头的文件? [英] How to remove files starting with double hyphen?
问题描述
我的 Unix 机器上有一些以
I have some files on my Unix machine that start with
--
例如--testings.html
如果我尝试删除它,我会收到以下错误:
If I try to remove it I get the following error:
cb0$ rm --testings.html
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
我试过了
rm "--testings.html" || rm '--testings.html'
但没有任何效果.
如何在终端上删除此类文件?
推荐答案
rm -- --testings.html
--
选项告诉 rm 将所有进一步的参数视为文件名,而不是选项,即使它们以 -
开头.
The --
option tells rm to treat all further arguments as file names, not as options, even if they start with -
.
这不是 rm 命令所特有的.getopt 函数实现了它,并且许多(所有?)UNIX 风格的命令都以同样的方式对待它:--
终止选项处理,并且它之后的任何内容都是常规参数.
This isn't particular to the rm command. The getopt function implements it, and many (all?) UNIX-style commands treat it the same way: --
terminates option processing, and anything after it is a regular argument.
http://www.gnu.org/software/hello/manual/libc/Using-Getopt.html#Using-Getopt
这篇关于如何删除以双连字符开头的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!