title: How to extract and chop version string from file in bash
body: <p>I have a simple text file ./version containing a version number. Unfortunately, sometimes the version number in the file is followed by whitespaces and newlines like</p>
  
  <pre><code>1.1.3[space][space][newline]
  [newline]
  [newline]
  </code></pre>
  
  <p>What is the best, easiest and shortest way to extract the version number into a bash variable without the trailing spaces and newlines? I tried</p>
  
  <pre><code>var=`cat ./version | tr -d ' '`
  </code></pre>
  
  <p>which works for the whitespaces but when appending a <code>tr -d '\n'</code> it does not work.</p>
  
  <p>Thanks,
  Chris</p>