Shell: how write multiline text file without escaping special symbols

bashshell

I know the question sounds to be discussed thousands times before. But somehow I can't find good solution.

Problem: I need to write multiline text from shell. The text might contain special chars sequences (starting from $) and I don't want to escape them. How to do this?

Currently I'm using cat:

cat <<TAGTEXTFILE > sometext.txt
Here is some text in which I don't want to escape sequences like: $().
I just want to see this text in this script exactly as 
it will look in resulting sometext.txt file.
TAGTEXTFILE

But with cat I have to escape this: $(). How to write multiline text without escaping special characters? Please don't offer to use Python, I need shell solution (bash or dash).

Best Answer

cat <<"TAGTEXTFILE" > sometext.txt
... some text ...
TAGTEXTFILE
Related Question