仅在命令行中删除 \ 文件

Gop*_*poi 1 linux command-line-interface

我不小心在我的 linux 中创建了一个“\”文件,如何恢复它。我试过 rm \ (因为它是转义字符,它不起作用), rm '\' 和 rm \\ 没有任何效果。

Ste*_*ski 6

正如您所说,您无法删除文件“\”目录,因为 \ 用作 shell 转义字符。

因此,请使用该\字符来转义名为“\”的文件/目录:

$ rm -i \\
Run Code Online (Sandbox Code Playgroud)

这是我的测试:

# Make and verify the problem
$ touch \\
$ ls -ld \\
-rw-r--r--  1 me  me  0 Oct 11 16:59 \

# Remove the file:
$ rm -i \\
remove \? y
$ ls -ld \\
ls: \: No such file or directory
Run Code Online (Sandbox Code Playgroud)