[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: list package version if installed (scriptable)



Hi Jim,

On Thu, Jan 07, 2021 at 08:12:52AM -0500, Jim Popovitch wrote:
> What is a script'able way to list a pkg version (or nothing if it is not
> installed)?

$ dpkg-query --showformat '${Version}\t${Status}\n' --show coreutils 
8.23-4  install ok installed
$ dpkg-query --showformat '${Version}\t${Status}\n' --show coreutils | awk '/installed/ { print $1 }'
8.23-4
$ dpkg-query --showformat '${Version}\t${Status}\n' --show wowbagger
dpkg-query: no packages found matching wowbagger
$ echo $?
1

Cheers,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting


Reply to: