title: When do I set IFS to a newline in Bash?
body: <p>I thought setting IFS to <code>$'\n'</code> would help me in reading an entire file into an array, as in:</p>
  
  <pre><code>IFS=$'\n' read -r -a array &lt; file
  </code></pre>
  
  <p>However, the above command only reads the first line of the file into the first element of the array, and nothing else.</p>
  
  <p>Even this reads only the first line into the array:</p>
  
  <pre><code>string=$'one\ntwo\nthree'
  IFS=$'\n' read -r -a array &lt;&lt;&lt; "$string"
  </code></pre>
  
  <p>I came across other posts on this site that talk about either using <code>mapfile -t</code> or a <code>read</code> loop to read a file into an array.</p>
  
  <p>Now my question is: <strong>when do I use <code>IFS=$'\n'</code> at all?</strong></p>