title: How to remove leading whitespace from a string in Bash
body: <p>For example, I have a string, "     some string", and I want to put "some string" in another string variable. How do I do that?</p>
  
  <p>My code:</p>
  
  <pre><code>function get_title() {
      t1=$(get_type "$1")
      t2="ACM Transactions"
      t3="ELSEVIER"
      t4="IEEE Transactions"
      t5="MIT Press"
      if [ "$t1"=="$t2" ];
          then
          title=$(less "$1" | head -1)
      elif [ "$t1"=="$t5" ];
      then
          title=$(less "$1" | head -3)
      fi
      echo "$title"
  }
  </code></pre>
  
  <p>As you can see the $title can return unwanted whitespace in front of text in center aligned texts. I want to prevent that.</p>