使用反引号时,Bash会抱怨here-document中的语法错误

前端之家收集整理的这篇文章主要介绍了使用反引号时,Bash会抱怨here-document中的语法错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在运行以下一段bash代码: @H_301_1@cat << END_TEXT _ _ | | | | __ _| |__ ___ __| | / _` | '_ \ / __/ _` | | (_| | |_) | (_| (_| | \__,_|_.__/ \___\__,_| END_TEXT

并收到一个错误

@H_301_1@bash: command substitution: line 1: Syntax error near unexpected token `|' bash: command substitution: line 1: ` | '_ \ / __/ _'
无需逃避反击.只需使用引用的here-doc字符串: @H_301_1@cat <<-'END_TEXT' _ _ | | | | __ _| |__ ___ __| | / _` | '_ \ / __/ _` | | (_| | |_) | (_| (_| | \__,_| END_TEXT

按照男人的说法:

If word is unquoted,all lines of the here-document are subjected to parameter expansion,command substitution,and arithmetic expansion,the character sequence \<newline> is ignored,and \ must be used to quote the characters \,$,and `.

猜你在找的Bash相关文章