title: bash script: how to compare version numbers
body: <p>I wrote a wrapper for rpmbuild that creates the source.tgz file in the <code>~/rpmbuild/SOURCES/</code>. However when I use this script on an older operating system; rpm's are built in <code>/usr/src/...</code>. So inside my bash script I would like to get the version number of rpmbuild; like this for example:</p>
  
  <pre><code>rpmbuild --version
  </code></pre>
  
  <p>which gives: <code>RPM version 4.11.1</code>. I'll get that into a variable; lets say</p>
  
  <pre><code>VERSION=4.11.1
  </code></pre>
  
  <p>Now how can I check easily inside my script that this is a version >=4.6.0 ? Do I really need to start parsing it into major, minor and bugfix and compare the three numbers, or is there another better way to do this? something like:</p>
  
  <pre><code>if [[ $VERSION &gt;= 4.6.0 ]]
  then
      # do stuff...
  fi
  </code></pre>