我正在尝试访问rm
目录及其内容,但是由于某种原因,rm
它忽略了转义字符。
在此示例中,我尝试Team Fortress 2
从中删除文件夹~/.local/share/Steam/SteamApps/common
:
[redacted@host common]$ rm -r Team\ Fortress\ 2/
/usr/bin/rm: cannot remove ‘Team’: No such file or directory
/usr/bin/rm: cannot remove ‘Fortress’: No such file or directory
/usr/bin/rm: cannot remove ‘2/’: No such file or directory
我也尝试用引号括起目录名称:
[redacted@host common]$ rm -r 'Team\ Fortress\ 2/'
/usr/bin/rm: cannot remove ‘Team\\’: No such file or directory
/usr/bin/rm: cannot remove ‘Fortress\\’: No such file or directory
/usr/bin/rm: cannot remove ‘2/’: No such file or directory
以下是 的输出rm --version
:
rm (GNU coreutils) 8.21
...
为什么会发生这种情况?
答案1
我的第一个猜测是R M是一个定义不明确的函数或脚本,例如
rm()
{
/usr/bin/rm -i $1
}
要找出答案,请执行以下命令:
type rm
如果我错了,它会说:
rm is /usr/bin/rm
如果我说对了,它会告诉你具体如何R M已被重新定义。