title: The easiest way to replace white spaces with (underscores) _ in bash
body: <p>recently I had to write a little script that parsed VMs in XenServer and as the names of the VMs are mostly with white spaces in e.g Windows XP or Windows Server 2008, I had to trim those white spaces and replace them with underscores _ . I found a simple solution to do this using sed which is great tool when it comes to string manipulation.</p>
  <pre><code>echo &quot;This is just a test&quot; | sed -e 's/ /_/g'
  </code></pre>
  <p>returns</p>
  <pre><code>This_is_just_a_test
  </code></pre>
  <p>Are there other ways to accomplish this?</p>