Semi-OT: Neat Trick regarding RPM query format

  • From: "Taylor, Chris David" <ChrisDavid.Taylor@xxxxxxxxxxxxxxx>
  • To: "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 2 Jul 2012 11:03:20 -0500

(Just sending this out there in case anyone is interested. If you have a better 
way, pass it on...)

rpm can provide you with the name and architecture when querying the installed 
rpms.

Typically rpm -q filename will only tell you it is installed, but not which 
architecture(s).


[root@rac2 /etc]$ rpm -qa glibc
glibc-2.5-81
glibc-2.5-81

To get the ARCH you can use --queryformat 
'%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}\n'

[root@rac2 /etc]$ rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE} 
%{ARCH}\n' glibc
glibc-2.5-81 x86_64
glibc-2.5-81 i686

To make this simpler, you can create (or add) an alias to /etc/popt, or ~/.popt:

rpm     exec -q                 rpmq -q --queryformat 
'%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n'

Take a look at /usr/lib/rpm/rpmopt-{version} to see a horde of aliases that rpm 
uses to get an idea what's available.



Chris Taylor

"Quality is never an accident; it is always the result of intelligent effort."
-- John Ruskin (English Writer 1819-1900)

Any views and/or opinions expressed herein are my own and do not necessarily 
reflect the views of Ingram Industries, its affiliates, its subsidiaries or its 
employees. 



--
//www.freelists.org/webpage/oracle-l


Other related posts: