加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

在linux中删除带有“-r”的文件名[复制]

发布时间:2020-12-14 02:41:16 所属栏目:Linux 来源:网络整理
导读:参见英文答案 How to cd into a directory with this name “-2” (starting with the hyphen)?6个 我无法使用rm -rf -r删除名为-r的文件名 是否有任何特殊技巧可以删除它? 解决方法 在Linux或类Unix系统中,您可能会遇到包含特殊字符的文件名,例如: ---;$?
参见英文答案 > How to cd into a directory with this name “-2” (starting with the hyphen)?6个
我无法使用rm -rf -r删除名为-r的文件名
是否有任何特殊技巧可以删除它?

解决方法

在Linux或类Unix系统中,您可能会遇到包含特殊字符的文件名,例如:
-
--
;
&
$
?
*
White spaces,backslashes and more.

The problem and solution

提示#1:在文件名的开头尝试./

删除名为’-file’的文件的语法如下:

$rm -v ./-file

removed `./-file’

提示#2:在文件名的开头尝试 –

A -- signals the end of options and disables further option processing     by   shell. 

Any arguments after the -- are treated as filenames and arguments.

$rm — -file

$rm — –file

$rm — ‘@#$%^&file’

$rmdir — ‘–dirnameHere’

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读