title: How to get the release value from an RPM -qi command
body: <p>I'm on RedHat, I need to get the value in the Release field.
  Take "wget" for an example.</p>
  
  <p>Here's the output I'm expected to get</p>
  
  <pre><code>WGET:    1.4.el6
  </code></pre>
  
  <p>Here's the output from rpm -qi wget</p>
  
  <pre><code>[luke@machine ~]# rpm -qi wget
  Name        : wget                         Relocations: (not relocatable)
  Version     : 1.12                              Vendor: Red Hat, Inc.
  Release     : 1.4.el6                       Build Date: Mon May 10 14:56:18 2010
  Install Date: Wed Oct  3 16:48:58 2012         Build Host: x86-012.build.bos.redhat.com
  Group       : Applications/Internet         Source RPM: wget-1.12-1.4.el6.src.rpm
  Size        : 1877597                          License: GPLv3+ and GFDL
  Signature   : RSA/8, Mon Aug 16 21:21:35 2010, Key ID 199e2f91fd431d51
  Packager    : Red Hat, Inc. &lt;http://bugzilla.redhat.com/bugzilla&gt;
  URL         : http://wget.sunsite.dk/
  Summary     : A utility for retrieving files using the HTTP or FTP protocols
  </code></pre>
  
  <p>How can I write a script to extract the "1.4.el6" from the Release field.</p>
  
  <p>I currently have</p>
  
  <pre><code>#!/bin/bash
  RELwg= rpm -qi wget
  # Do string manipulation of $RELwg here
  wg="WGET:   "
  echo $wg$RELwg
  </code></pre>
  
  <p>But here's the output I get;</p>
  
  <pre><code>Release     : 1.4.el6                       Build Date: Mon May 10 14:56:18 2010
  WGET:
  </code></pre>
  
  <p>I know I have to do some string extraction, to get the number.</p>
  
  <ul>
  <li>Get the index of the 1, seems to always be constant at 15</li>
  <li>Get the index of the B in Build Date</li>
  <li>Get the sub string inbetween 15 and whatever B is</li>
  </ul>
  
  <p>Removing the space between "RELwg= rpm -qi wget" in my current script, I just get an error saying that </p>
  
  <blockquote>
    <p>./GetRPMVersions.sh: line 12: -qi: command not found</p>
  </blockquote>
  
  <p>Mainly my current predicament is to addign the ouput of rpm -qi wget | grep Release to a variable.</p>
  
  <p>Any input on the string manipulation is welcome.</p>