Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on 64 bits RHEL and I want rpm -q to use these tags by default:

'%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}'

Other than typing the tags by hand or defining an alias, is there a way I can configure this in ~/.rpmrc or another config file?

share|improve this question
up vote 0 down vote accepted

The %_query_all_fmt macro defines what format is used. Set it in ~/.rpmmacros.

%_query_all_fmt %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}
share|improve this answer
    
Works great, thanks! Before I accept your answer, can you please tell me where you found this? I searched for the answer but couldn't find it. Thanks! – Philippe A. Jul 28 '10 at 17:56
    
I can't remember. I've been using rpm for... about a decade, and it's one of the things I picked up along the way. Anyways, rpm --showrc is your friend. – Ignacio Vazquez-Abrams Jul 28 '10 at 17:59

I found below output most practical:

rpm -q --qf \
    '%{name}-%|epoch?{%{epoch}:}:{}|%{version}-%{release}%|arch?{.%{arch}}:{}|\n'

in ~/.rpmmacros you can skip adding \n at the end of the format. Basically it skips displaying %{epoch} or %{arch} if package doesn't have it set. For example see output of rpm -q tar openssl bind-libs perl-CGI gpg-pubkey on Scientific Linux 6.2.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .