echo "!omg"输出-bash: !omg: event not found
!omg字符串输出到控制台?node -e "var code = function(){ console.log('which contains a lot of !'); }; !func();"发布于 2013-12-13 12:50:49
使用单引号:
echo '!omg'如果您的输入中有引号,例如打印console.log('lalala'),请说:
echo $'console.log(\'lalala\')'或者,说:
cat | command << EOF
my_string_with_crazy_characters
EOF最后一个表单不要求您转义输入中的任何字符。
发布于 2013-12-13 13:03:40
我更喜欢取消shell变量histchars,以有效地禁用历史扩展:
$ echo !omg
bash: !omg: event not found
$ histchars=
$ echo !omg
!omg发布于 2013-12-13 13:01:42
您可以按以下方式关闭history expansion
[username@hostname ~]$ set +o histexpand
[username@hostname ~]$ echo hello!world!anything
hello!world!anything打开
[username@hostname ~]$ set -o histexpand
[username@hostname ~]$ echo hello!world!anything
-bash: !world!anything: event not foundhttps://stackoverflow.com/questions/20566961
复制相似问题