回声"#&QUOT!;失败 - "事件未发现"
问题描述:
以下失败,我不明白为什么:
The following fails and I don't understand why:
$ echo "#!"
下面还失败,相同的错误消息:
the following also fails with the same error message:
$ echo "\#!"
错误消息:
-bash: !": event not found
为什么会失败?应如何回声
来代替呢?
答
的!
字符用于 CSH
风格历史扩展。
The !
character is used for csh
-style history expansion.
如果您不使用此功能,设置+ O histexpand
(又名设置+ H
)关闭此行为。它是关闭的脚本,但往往启用交互使用。
If you do not use this feature, set +o histexpand
(aka set +H
) turns off this behavior. It is turned off for scripts, but often enabled for interactive use.
作为一种变通方法,您可以使用单引号代替双引号的。
As a workaround, you can use single quotes instead of double quotes.