如何删除文件,开始双连字符? [英] How to remove files starting with double hyphen?

查看:122
本文介绍了如何删除文件,开始双连字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有跟我的启动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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆