title: How does "cat << EOF" work in bash?
body: <p>I needed to write a script to enter multi-line input to a program (<code>psql</code>).</p>
  
  <p>After a bit of googling, I found the following syntax works:</p>
  
  <pre><code>cat &lt;&lt; EOF | psql ---params
  BEGIN;
  
  `pg_dump ----something`
  
  update table .... statement ...;
  
  END;
  EOF
  </code></pre>
  
  <p>This correctly constructs the multi-line string (from <code>BEGIN;</code> to <code>END;</code>, inclusive) and pipes it as an input to <code>psql</code>.</p>
  
  <p>But I have no idea how/why it works, can some one please explain?</p>
  
  <p>I'm referring mainly to <code>cat &lt;&lt; EOF</code>, I know <code>&gt;</code> outputs to a file, <code>&gt;&gt;</code> appends to a file, <code>&lt;</code> reads input from file. </p>
  
  <p>What does <code>&lt;&lt;</code> exactly do?</p>
  
  <p>And is there a man page for it?</p>