is there a standard for getting a command's version number?

Robert P. J. Day rpjday at crashcourse.ca
Sat Dec 22 15:01:29 UTC 2007


On Sat, 22 Dec 2007, Jacques B. wrote:

> Not at my Linux box so can't validate this, but could you get it
> from rpm -qa | grep {command_name}?  Doesn't the rpm package name
> always contain the version number?  If so at least the format would
> be more standardized thus easier to parse.

but the command name doesn't necessarily need to match the package
name from whence it came, as in:

  $ rpm -qf /bin/ls
  coreutils-6.9-12.fc8

obviously, this isn't a life-or-death issue but, given the frequency
with which people might want to check the version number of a command,
i am a bit surprised that there's no GNU-wide standard option
(--exactversion?) that just gives it to you.

did no one ever suggest such a thing?  just curious.

rday

p.s.  one option is to just use rpm and queryformat, as in:

$ rpm -q --queryformat "%{VERSION}\n" $(rpm -qf $(which grep))
2.5.1
$

or something to that effect.
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================




More information about the users mailing list