printf \'<a>\&#39; gives error - cannot find the file specified

时间:2017-10-15 01:50:43

标签: linux bash printf

When I run printf '<a>' I get what I expect.

When I run printf \'<a>\' I get ... cannot find the file specified.

When I am executing printf from NodeJS v6.11.3 it is forcing the latter. Anyone know why and how I might get past this?

I am running git bash on Windows.

1 个答案:

答案 0 :(得分:4)

如果您使引号不特殊(通过转义它们),则<将成为重定向并尝试从名为a的文件重定向stdin。您只需要找到正确的引用/转义,以确保printf没有太多的转义。

如果您尝试打印单引号,请尝试

 printf "'<a>'"