I'm adding two solutions that are more OS-agnostic than dpkg-query
(which doesn't work on, e.g. Mac OS X). First, often the version information is included in the path where the package is installed, and so you can use which
to display it:
$ which ncdump
/usr/local/netcdf-4.2_optimized/bin/ncdump
Second, many docstrings also include the version number, so just printing them out will do the trick. For example, print the usage instructions of ncdump
by calling it with with no arguments:
$ ncdump
ncdump [-c|-h] [-v ...] [[-b|-f] [c|f]] [-l len] [-n name] [-p n[,n]] [-k] [-x] [-s] [-t|-i] [-g ...] [-w] file
[-c] Coordinate variable data and header information
...
file Name of netCDF file
netcdf library version 4.2 of May 23 2012 12:14:03 $