Bash complains about syntax errors in this document when using feedback signals

I run the following snippet of bash code:

cat << END_TEXT _ _ | | | | __ _| |__ ___ __| | / _` | '_ \ / __/ _` | | (_| | |_) | (_| (_| | \__,_|_.__/ \___\__,_| END_TEXT 

and I get an error:

 bash: command substitution: line 1: syntax error near unexpected token `|' bash: command substitution: line 1: ` | '_ \ / __/ _' 
+5
source share
2 answers

No need to avoid reverse steps. Just use the quoted here-doc line as:

 cat <<-'END_TEXT' _ _ | | | | __ _| |__ ___ __| | / _` | '_ \ / __/ _` | | (_| | |_) | (_| (_| | \__,_|_.__/ \___\__,_| END_TEXT 

According to man bash :

If a word is not specified , all lines of this document are expanded with parameters, command substitution and arithmetic expansion, the \<newline> character sequence is ignored, and \ - is used to denote the characters \ , $ and ` .

+7
source

These are the return outputs. Most of the content in the document here is not replicated and used as is, but backlinks change that.

Solution: avoid them even if this ruins the layout of your script:

 cat << END_TEXT _ _ | | | | __ _| |__ ___ __| | / _\` | '_ \ / __/ _\` | | (_| | |_) | (_| (_| | \__,_|_.__/ \___\__,_| END_TEXT 
0
source

Source: https://habr.com/ru/post/1275314/


All Articles