如何转义 console/command 行中的 '-' 字符

How to escape '-' character in console/command line

我有一个名为 - 的文件。如何将文件名作为参数传递给控制台命令?.

我的意思是有没有办法在控制台中转义 - 字符?

对于某些命令,我​​知道你可以说它是命令行参数的结尾,带有双-

例如:

touch -
rm -- -
rm: Remove -? y

您可以为其添加路径,例如:

cat ./-

David A Wheeler 写了一篇关于如何在 shell 脚本中处理文件名的文章 in-depth essay