title: Assigning the output of a bash string manipulation to a variable
body: <p>On Ubuntu 16.04, I have a bash script which I run as root. I want to remove all spaces from the user's input, and assign the trimmed string to a variable.</p>
  
  <pre><code>read -p "Enter username: " USERNAME
  echo "$USERNAME" | sed s/' '/''/g
  TRIM="$USERNAME" | sed s/' '/''/g
  echo $TRIM
  echo "Done"
  </code></pre>
  
  <p>Here's some sample input and output:</p>
  
  <blockquote>
    <p>Enter username: h j k l<br>
    hjkl</p>
    
    <p>Done</p>
  </blockquote>
  
  <p>$TRIM is empty.<br>
  What change do I need to make to get $TRIM to contain the result?</p>