title: Reading a space-delimited string into an array in Bash
body: <p>I have a variable which contains a space-delimited string:</p>
  
  <pre><code>line="1 1.50 string"
  </code></pre>
  
  <p>I want to split that string with space as a delimiter and store the result in an array, so that the following:</p>
  
  <pre><code>echo ${arr[0]}
  echo ${arr[1]}
  echo ${arr[2]}
  </code></pre>
  
  <p>outputs</p>
  
  <pre><code>1
  1.50
  string
  </code></pre>
  
  <p>Somewhere I found a solution which doesn't work:</p>
  
  <pre><code>arr=$(echo ${line})
  </code></pre>
  
  <p>If I run the echo statements above after this, I get:</p>
  
  <pre><code>1 1.50 string
  [empty line]
  [empty line]
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>IFS=" "
  arr=$(echo ${line})
  </code></pre>
  
  <p>with the same result. Can someone help, please?</p>