title: marking end of file while redirecting to a file in a non-interactive bash script using cat
body: <p>I'm trying to redirect a multi-line string to a file. The string contains special chars like <strong>quota</strong> and looks like this:</p>
  
  <pre><code>import "this"
  import "that"
  main() {
      println("some text here");
  }
  </code></pre>
  
  <p>I can use <code>echo</code> such as:</p>
  
  <pre><code>echo "import \"this\"
  import \"that\"
  main() {
      println(\"some text here\");
  }" &gt; myfile.txt
  </code></pre>
  
  <p>The problem with this approach is that I need to escape all <strong>quota</strong> chars. I thought about using <code>cat</code> to eliminate the need for escaping. It works well in interactive shells so that I can type <code>cat &gt; myfile.txt</code> and then write my string without escaping and then mark the end of file with <code>&lt;control&gt;d</code>.</p>
  
  <p>How can I mark <code>EOF</code> in the script without the actual key sequence <code>&lt;control&gt;d</code>?</p>