How to cat <> a file containing code?

You only need a minimal change; single-quote the here-document delimiter after <<. or equivalently backslash-escape it: Without quoting, the here document will undergo variable substitution, backticks will be evaluated, etc, like you discovered. If you need to expand some, but not all, values, you need to individually escape the ones you want to prevent. will produce … Read more

How does “cat << EOF" work in bash?

This is called heredoc format to provide a string into stdin. See https://en.wikipedia.org/wiki/Here_document#Unix_shells for more details. From man bash: Here Documents This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen. All of the lines read up to that point are then used as the … Read more

Creating multiline strings in JavaScript

Update: ECMAScript 6 (ES6) introduces a new type of literal, namely template literals. They have many features, variable interpolation among others, but most importantly for this question, they can be multiline. A template literal is delimited by backticks: (Note: I’m not advocating to use HTML in strings) Browser support is OK, but you can use transpilers to be more … Read more

Creating multiline strings in JavaScript

Update: ECMAScript 6 (ES6) introduces a new type of literal, namely template literals. They have many features, variable interpolation among others, but most importantly for this question, they can be multiline. A template literal is delimited by backticks: (Note: I’m not advocating to use HTML in strings) Browser support is OK, but you can use … Read more