如何从 Unix 中删除文件(名称中有空格)?

Gau*_*rav 1 unix rm

如何从 Unix 中删除文件(名称中有空格)?

小智 6

另一种格式:

rm file\ with\ spaces\ in\ the\ name
Run Code Online (Sandbox Code Playgroud)


小智 5

使用引号将文件名括起来:

rm "file with a space.txt"
Run Code Online (Sandbox Code Playgroud)

更新:使用引号将整个文件路径括起来:

rm "../dir with spaces/file with spaces.txt"
Run Code Online (Sandbox Code Playgroud)

引号告诉 shell 命令将带引号的字符串解释为一个参数(因此您可以在大多数 shell 命令中使用它)。