小智 16
在 Linux 或类 Unix 系统中,您可能会遇到带有特殊字符的文件名,例如:
-
--
;
&
$
?
*
White spaces, backslashes and more.
Run Code Online (Sandbox Code Playgroud)
问题和解决方案
提示 #1:尝试在文件名开头使用 ./
删除名为“-file”的文件的语法如下:
$ rm -v ./-file
删除了`./-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.
Run Code Online (Sandbox Code Playgroud)
$ rm ---文件
$ rm -- -- 文件
$ rm -- '@#$%^&file'
$ rmdir -- '--dirnameHere'
fak*_*ken 12
如rm
手册页所述:
要删除名称以“-”开头的文件,例如“-foo”,请使用以下命令之一:
Run Code Online (Sandbox Code Playgroud)rm -- -foo rm ./-foo
所以,在你的情况下:
rm -- -r
Run Code Online (Sandbox Code Playgroud)
或者
rm ./-r
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1035 次 |
最近记录: |