title: Linux replace space to newline for a string
body: <p>I have a string and I am trying to replace the space to newline</p>
  
  <p>my original string</p>
  
  <pre><code>xxx xxx xxx xxx
  </code></pre>
  
  <p>If I use the following command then it works</p>
  
  <pre><code>echo $string | sed 's/ /\n/g'
  </code></pre>
  
  <p>However if I want to assign the new string to another variable e.g.</p>
  
  <pre><code>newString=`echo $string | sed 's/ /\n/g'`
  echo $newString
  </code></pre>
  
  <p>It doesn't work...</p>
  
  <p>Does anyone know why?</p>