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

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

问题描述

我的 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屋!

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