This example not work in my case. This example is about bash -c but there is no cat example.
How Escaping a dollar sign using bash -c ? This is my code. It is not work correct. I get empty file. But I want text $6 in file.
bash -c "cat <<EOF > /home/pi/file.txt
\$6
EOF"
P.S. I need bash -c because I plan to use cat with sudo.