title: How to read the file content into a variable in one go?
body: <p>In Java, if you know for certain a file is very small, you can use <code>readBytes()</code> method to read the content in one go instead of read it line by line or using buffer. </p>
  
  <p>Just wondering in shell script, I know we can do something like:</p>
  
  <pre><code>    while read line
      do
        echo $line
        LINE = $line
      done &lt; "test.file"
      echo $LINE
  </code></pre>
  
  <p>If my test.file is like:</p>
  
  <pre><code>testline1
  testline2
  testline3
  </code></pre>
  
  <p>This only gives me the last line to <code>$LINE</code>. <code>$LINE</code> contains "testline3". </p>
  
  <p>My question is: How can I read the whole file with multiple lines into one single variable,so I can get <code>$LINE="testline1\ntestline2\ntestline3"</code>?</p>