如何删除文件,开始双连字符? [英] How to remove files starting with double hyphen?
问题描述
我有跟我的启动Unix机器上的一些文件
-
例如。 - testings.html
如果我尝试删除它,我收到以下错误:
CB0 $ RM --testings.html
RM:非法选项 - -
用法:RM [-f | -i] [-dPRrvW]文件...
取消链接文件
我试过
RM--testings.html|| RM'--testings.html
但没有任何工程。
如何删除终端上这样的文件?
RM - --testings.html
的 -
选项告诉RM把所有的参数再为文件名,而不是选择,即使他们开始与 -
。
这是不是特别rm命令。 getopt函数的实现它,很多(所有?)UNIX风格的命令把它以同样的方式: -
终止选项处理,和任何之后是一个普通的说法。
<一个href=\"http://www.gnu.org/software/hello/manual/libc/Using-Getopt.html#Using-Getopt\">http://www.gnu.org/software/hello/manual/libc/Using-Getopt.html#Using-Getopt
I have some files on my Unix machine that start with
--
e.g. --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
I tried
rm "--testings.html" || rm '--testings.html'
but nothing works.
How can I remove such files on terminal?
rm -- --testings.html
The --
option tells rm to treat all further arguments as file names, not as options, even if they start with -
.
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屋!